Get Document
Returns one document: its status, custom metadata, row_version, active revision, and latest indexing task.
For how document IDs and document file IDs relate, see Browse Documents and Chunks.
curl --request GET \
--url https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/logical-documents/{document_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/logical-documents/{document_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/logical-documents/{document_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/logical-documents/{document_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/logical-documents/{document_id}"
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))
}HttpResponse<String> response = Unirest.get("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/logical-documents/{document_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/logical-documents/{document_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"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"
}
}Authorizations
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 base ID: the last segment of the Service API endpoint shown in the knowledge base's API Access dialog (…/knowledge-fs/spaces/<knowledge base ID>), and the segment after /datasets/new/ in the address bar.
The document ID, from List Documents.
Response
The document.
The active revision: the content the knowledge base serves. Pass its revision to List Chunks and its document_asset_id to Get Document File. null while no revision is active.
Show child attributes
Show child attributes
Number of the active revision. null while none is active.
When the document was created, ISO 8601.
When the document was disabled in Dify, ISO 8601.
Internal ID of whoever disabled the document. Not needed to call this API.
false after the document is disabled in Dify. Re-index Documents skips disabled documents.
Document ID. It stays the same when the document's content is updated.
Internal ID of the knowledge base. Not the knowledge base ID in the path.
The newest indexing task behind the document's revisions, with 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 attributes
Show child attributes
For a document imported from a source, the item's identifier there: the providerItemId sent to Import Source Items, or the page_id of a website page.
Change counter. Send it as 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.
Source the document came from. 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.
Document title.
When the document last changed, ISO 8601.
Custom metadata, keyed by metadata field name. Change it with Update Document Metadata or in Dify.
Was this page helpful?
curl --request GET \
--url https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/logical-documents/{document_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/logical-documents/{document_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/logical-documents/{document_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/logical-documents/{document_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/logical-documents/{document_id}"
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))
}HttpResponse<String> response = Unirest.get("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/logical-documents/{document_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/logical-documents/{document_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"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"
}
}