List Documents
Lists the documents in a knowledge base, oldest first, with each document’s status, custom metadata, active revision, and latest indexing task.
Disabled documents are listed with enabled: false. Documents being deleted, or whose file or source is being deleted, are left out.
A page can hold fewer than limit documents, so follow next_cursor until it is null.
For how document IDs and document file IDs relate, see Browse Documents and Chunks.
curl --request GET \
--url https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/logical-documents \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/logical-documents"
headers = {
"Authorization": "Bearer <token>",
}
response = requests.request("GET", url, headers=headers)
print(response.text)const response = await fetch('https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/logical-documents', {
method: 'GET',
headers: {
'Authorization': 'Bearer <token>'
}
});
const data = await response.json();
console.log(data);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/logical-documents',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer <token>',
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;package main
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/logical-documents"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/logical-documents"))
.header("Authorization", "Bearer <token>")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());require 'uri'
require 'net/http'
url = URI('https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/logical-documents')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = url.scheme == 'https'
request = Net::HTTP::Get.new(url)
request['Authorization'] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": [
{
"active": {
"activated_at": "2026-10-20T08:16:05Z",
"content_hash": "4f7c2d9a1b3e5f60718293a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4",
"created_at": "2026-10-20T08:15:42Z",
"document_asset_id": "6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b",
"document_asset_version": 1,
"document_id": "2f6b8d1a-7c3e-4a5b-9d0e-1f2a3b4c5d6e",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"mime_type": "application/pdf",
"revision": 2,
"size_bytes": 482113,
"state": "active"
},
"active_revision": 2,
"created_at": "2026-09-03T10:02:11Z",
"disabled_at": null,
"disabled_by_subject_id": null,
"enabled": true,
"id": "2f6b8d1a-7c3e-4a5b-9d0e-1f2a3b4c5d6e",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"latest_task": {
"can_cancel": false,
"can_retry": false,
"completed_at": "2026-10-20T08:16:05Z",
"created_at": "2026-10-20T08:15:42Z",
"document_id": "2f6b8d1a-7c3e-4a5b-9d0e-1f2a3b4c5d6e",
"document_revision": 2,
"document_title": null,
"error_code": null,
"error_message": null,
"failure": null,
"failures": null,
"id": "c4e8a2f6-1b3d-4e5f-8a9b-0c1d2e3f4a5b",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"operation": "document_processing",
"progress_completed": 1,
"progress_failed": 0,
"progress_percent": 100,
"progress_total": 1,
"semantic_enrichment": {
"error_code": null,
"error_message": null,
"failure": null,
"nodes_completed": 0,
"nodes_total": null,
"provider_calls": null,
"provider_calls_maximum": null,
"state": "disabled",
"updated_at": null
},
"source_id": null,
"source_title": null,
"state": "completed",
"task_kind": "document",
"updated_at": "2026-10-20T08:16:05Z"
},
"provider_item_id": null,
"row_version": 4,
"source_id": null,
"status": "ready",
"title": "handbook.pdf",
"updated_at": "2026-10-20T08:16:05Z",
"user_metadata": {
"owner": "support-team",
"product_line": "billing",
"review_date": "2026-12-01T00:00:00Z"
}
},
{
"active": {
"activated_at": "2026-10-19T03:04:51Z",
"content_hash": "9c1e5b7d3f2a4c6e8b0d1f3a5c7e9b2d4f6a8c0e1b3d5f7a9c2e4b6d8f0a1c3e",
"created_at": "2026-10-19T03:04:12Z",
"document_asset_id": "7d2e4f6a-8b0c-4d1e-9f3a-5b7c9d1e3f5a",
"document_asset_version": 1,
"document_id": "3a7e9c1b-5d2f-4e8a-9b0c-1d2e3f4a5b6c",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"mime_type": "text/markdown",
"revision": 1,
"size_bytes": 18342,
"state": "active"
},
"active_revision": 1,
"created_at": "2026-10-19T03:04:12Z",
"disabled_at": null,
"disabled_by_subject_id": null,
"enabled": true,
"id": "3a7e9c1b-5d2f-4e8a-9b0c-1d2e3f4a5b6c",
"knowledge_space_id": "9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b",
"latest_task": null,
"provider_item_id": "5e0f9a6c2b8d4e1f7a3c9b5d1e7f3a9c5b1d7e3f9a5c1b7d3e9f5a1c7b3d9e5f",
"row_version": 1,
"source_id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"status": "ready",
"title": "Pricing | Docs site",
"updated_at": "2026-10-19T03:04:51Z",
"user_metadata": {}
}
],
"next_cursor": null
}{
"code": "knowledge_fs_invalid_request",
"message": "Agent Knowledge Base request is invalid.",
"status": 400,
"violations": [
{
"field": [
"limit"
],
"type": "less_than_equal"
}
]
}{
"code": "knowledge_fs_invalid_request",
"failure": {
"category": "validation",
"code": "KNOWLEDGE_FS_INVALID_REQUEST",
"message": "The Agent Knowledge Base request is invalid.",
"retryPolicy": "never",
"traceId": "7f3c1a90-2e64-4b7d-8a51-6c0d9e2f4b83"
},
"message": "The Agent Knowledge Base request is invalid.",
"status": 400
}{
"code": "knowledge_fs_invalid_credential",
"message": "Invalid Agent Knowledge Base service credential.",
"status": 401
}{
"code": "unauthorized",
"message": "Access token is invalid",
"status": 401
}{
"code": "forbidden",
"message": "Sorry, you have reached the knowledge base request rate limit of your subscription.",
"status": 403
}{
"code": "knowledge_fs_access_denied",
"message": "Agent Knowledge Base operation is not allowed.",
"status": 403
}{
"code": "knowledge_fs_access_denied",
"failure": {
"action": "contact_admin",
"category": "authorization",
"code": "KNOWLEDGE_FS_ACCESS_DENIED",
"message": "You do not have permission to perform this Agent Knowledge Base operation.",
"retryPolicy": "never",
"traceId": "7f3c1a90-2e64-4b7d-8a51-6c0d9e2f4b83"
},
"message": "You do not have permission to perform this Agent Knowledge Base operation.",
"status": 403
}{
"code": "not_found",
"message": "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.",
"status": 404
}{
"code": "knowledge_fs_upstream_unavailable",
"failure": {
"action": "contact_admin",
"category": "internal",
"code": "KNOWLEDGE_FS_INTERNAL_ERROR",
"message": "Agent Knowledge Base could not complete the operation. Try again, or contact an administrator with the error reference.",
"retryPolicy": "manual",
"traceId": "5e2a9c17-3b4d-4f60-8a1b-2c3d4e5f6a7b"
},
"message": "Agent Knowledge Base could not complete the operation. Try again, or contact an administrator with the error reference.",
"status": 502
}{
"code": "knowledge_fs_upstream_unavailable",
"message": "Agent Knowledge Base is unavailable.",
"status": 502
}{
"code": "knowledge_fs_operation_unavailable",
"message": "Agent Knowledge Base operation is not available.",
"status": 503
}{
"code": "knowledge_fs_operation_unavailable",
"failure": {
"action": "retry",
"category": "dependency",
"code": "KNOWLEDGE_FS_UNAVAILABLE",
"message": "A service required by Agent Knowledge Base is temporarily unavailable.",
"retryPolicy": "manual",
"traceId": "5e2a9c17-3b4d-4f60-8a1b-2c3d4e5f6a7b"
},
"message": "A service required by Agent Knowledge Base is temporarily unavailable.",
"status": 503
}Authorization
Every request authenticates with an API key: Authorization: Bearer {API_KEY}. App endpoints take an app API key; knowledge endpoints take a knowledge base API key (Get Started).
Keep keys server-side; never embed them in client code. Requests with a missing or invalid key fail with HTTP 401 (unauthorized).
Path parameters
…/knowledge-fs/spaces/<knowledge base ID>), and the segment after /datasets/new/ in the address bar.Query parameters
Responses
Show child attributesHide child attributes
revision to List Chunks and its document_asset_id to Get Document File. null while no revision is active.Show child attributesHide child attributes
null for a revision that never became active.version when this revision was created.id of Get Document.candidate while the revision is being indexed, active for the revision the knowledge base serves, superseded after a newer revision became active, failed when indexing failed.null while none is active.false after the document is disabled in Dify. Re-index Documents skips disabled documents.task_kind: document. Follow it with Get Document Indexing Task using its id. null when there is none, and always null in the Update Document Metadata response.Show child attributesHide child attributes
task_kind: document, cancel it with Cancel Indexing Task using id. A bulk task has no cancel operation in this API, even when can_cancel is true.task_kind: document, retry it with Retry Indexing Task using id.null while it runs.state is failed.error_code. Can differ from failure.message.state is failed. null otherwise.Show child attributesHide child attributes
configure_model, configure_parser, configure_source, contact_admin, reupload, or retry. null when not applicable; omitted from HTTP error bodies.authorization, canceled, configuration, conflict, dependency, internal, not_found, rate_limit, timeout, or validation.KNOWLEDGE_FS_CONFLICT or SOURCE_CREDENTIAL_TEST_FAILED.attempt, currentRowVersion, documentCount, expectedRowVersion, fileSizeBytes, limit, maxFileSizeBytes, maxItems, modelType, providerKind, retryAfterSeconds, and status. null when there are none; omitted from HTTP error bodies.automatic (the service retries on its own), manual (retry yourself), after_configuration (fix the knowledge base's setup in Dify first), or never (change the request).query_generation or credential-test. null when not applicable; omitted from HTTP error bodies.null in a successful response containing failure details, or omitted from an HTTP error body.null for other kinds.Show child attributesHide child attributes
error_code.Show child attributesHide child attributes
configure_model, configure_parser, configure_source, contact_admin, reupload, or retry. null when not applicable; omitted from HTTP error bodies.authorization, canceled, configuration, conflict, dependency, internal, not_found, rate_limit, timeout, or validation.KNOWLEDGE_FS_CONFLICT or SOURCE_CREDENTIAL_TEST_FAILED.attempt, currentRowVersion, documentCount, expectedRowVersion, fileSizeBytes, limit, maxFileSizeBytes, maxItems, modelType, providerKind, retryAfterSeconds, and status. null when there are none; omitted from HTTP error bodies.automatic (the service retries on its own), manual (retry yourself), after_configuration (fix the knowledge base's setup in Dify first), or never (change the request).query_generation or credential-test. null when not applicable; omitted from HTTP error bodies.null in a successful response containing failure details, or omitted from an HTTP error body.task_kind: document, a bulk task ID for document_bulk, or a source run ID for source. For a document_delete task from Delete Document, it's the deletion job ID: poll Get Deletion Job with it.What the task does:
document_processing: an indexing task.document_reindex,document_upload,document_delete: a bulk task. Bulk uploads and deletions come from Dify. A deletion with Delete Document also appears as adocument_deletetask. Other deletions over this API create only a deletion job.source_sync,source_crawl_preview,source_crawl_import,source_online_document_import,source_online_drive_import: a source run.
progress_completed.progress_completed. 1 for an indexing task.null for other kinds. Indexing finishes the knowledge graph before publishing, so it doesn't schedule this step. state is not_scheduled while the task runs and disabled once it has ended. nodes_completed stays 0.Show child attributesHide child attributes
state is failed.error_code. Can differ from failure.message.state is failed. null otherwise.Show child attributesHide child attributes
configure_model, configure_parser, configure_source, contact_admin, reupload, or retry. null when not applicable; omitted from HTTP error bodies.authorization, canceled, configuration, conflict, dependency, internal, not_found, rate_limit, timeout, or validation.KNOWLEDGE_FS_CONFLICT or SOURCE_CREDENTIAL_TEST_FAILED.attempt, currentRowVersion, documentCount, expectedRowVersion, fileSizeBytes, limit, maxFileSizeBytes, maxItems, modelType, providerKind, retryAfterSeconds, and status. null when there are none; omitted from HTTP error bodies.automatic (the service retries on its own), manual (retry yourself), after_configuration (fix the knowledge base's setup in Dify first), or never (change the request).query_generation or credential-test. null when not applicable; omitted from HTTP error bodies.null in a successful response containing failure details, or omitted from an HTTP error body.0 until state is ready, then the same as nodes_total.null until known.not_scheduled, pending, running, ready, failed, or disabled.task_ids.queued, running, completed, failed, or canceled, mapped from the task's own state. A crawl preview waiting for its pages to be selected is completed.
For the exact state, read an indexing task with Get Indexing Task and a source run with Get Source Run.
document (an indexing task), document_bulk (a bulk task), or source (a source run).providerItemId sent to Import Source Items, or the page_id of a website page.expectedRowVersion on Update Document Metadata, and as expectedRevision on Delete Document. It increases on metadata updates, when a new revision becomes active or the active revision's file is deleted, when the document's source is deleted with documents=keep, and when the document is enabled or disabled in Dify.null for uploaded files.pending (no revision active yet), ready (a revision is active), failed (the first revision failed to index and none is active), or deleting. A ready document stays ready when a later revision fails.null on the last page. Send it back as cursor.