GET/datasets/{dataset_id}/documents/{document_id}

Get Document

Returns detailed information for a single document.

3 parameters
dataset_idstringrequired
Knowledge base ID, from [List Knowledge Bases](/en/api-reference/knowledge-bases/list-knowledge-bases). For a scoped key, [copy the ID from the Dify URL](/en/api-reference/guides/knowledge#knowledge-base-id).
document_idstringrequired
Document ID. From [List Documents](/en/api-reference/documents/list-documents).
metadatastringoptional
`all` returns all fields including metadata. `only` returns only `id`, `doc_type`, and `doc_metadata`. `without` returns all fields except `doc_type` and `doc_metadata`.
Allowed:allonlywithoutDefault:all

4 status codes
200Document details. The returned fields depend on the `metadata` query parameter.
archivedbooleanoptional
Whether the document is archived.
average_segment_lengthnumberoptional
Average character length of chunks.
completed_atnumberoptional
Unix timestamp when processing completed, `null` if not yet completed.
created_atnumberoptional
Unix timestamp of document creation.
created_bystringoptional
ID of the user who created the document.
created_fromstringoptional
Origin of the document. `api` for API creation, `web` for UI creation.
data_source_infoobjectoptional
Data source details. For file uploads, this detail endpoint returns the full file object under `upload_file` (the list endpoint returns only `upload_file_id`).
data_source_typestringoptional
How the document was uploaded. `upload_file` for file uploads, `notion_import` for Notion imports.
dataset_process_ruleobjectoptional
Knowledge-base-level processing rule configuration.
dataset_process_rule_idstringoptional
ID of the processing rule applied to this document.
disabled_atnumberoptional
Unix timestamp when the document was disabled, `null` if enabled.
disabled_bystringoptional
ID of the user who disabled the document, `null` if enabled.
display_statusstringoptional
Display-friendly indexing status for the UI.
doc_formstringoptional
Document chunking mode. `text_model` for standard text, `hierarchical_model` for parent-child, `qa_model` for QA pairs.
doc_languagestringoptional
Language of the document content.
doc_metadataarray<object>optional
Custom metadata key-value pairs for this document.
doc_typestringoptional
Document type classification, `null` if not set.
document_process_ruleobjectoptional
Document-level processing rule configuration.
enabledbooleanoptional
Whether the document is enabled for retrieval.
errorstringoptional
Error message if indexing failed, `null` otherwise.
hit_countintegeroptional
Number of times this document has been retrieved.
idstringoptional
Document identifier.
indexing_latencynumberoptional
Time taken for indexing in seconds, `null` if not completed.
indexing_statusstringoptional
Current indexing status, e.g. `waiting`, `parsing`, `cleaning`, `splitting`, `indexing`, `completed`, `error`, `paused`.
namestringoptional
Document name.
need_summarybooleanoptional
Whether the document needs summary generation.
positionintegeroptional
Position index within the knowledge base.
segment_countintegeroptional
Number of chunks in the document.
summary_index_statusstringoptional
Status of summary indexing, `null` if summary index is not enabled.
tokensintegeroptional
Number of tokens in the document.
updated_atnumberoptional
Unix timestamp of last update, `null` if never updated.
400`invalid_metadata` : The `metadata` query parameter value is invalid (must be `all`, `only`, or `without`).

One documented failure

  • invalid_metadata

    Invalid metadata value: full

    invalid_metadata

403- `forbidden` : You do not have permission to access this document. - `forbidden` : Knowledge base API access is not enabled. - `forbidden` : The API key is scoped to specific knowledge bases, and this knowledge base is not one of them.

One documented failure

  • forbidden

    No permission.

    forbidden (no permission)

404`not_found` : Document not found. Also returned as "Dataset not found." when the knowledge base itself does not exist.

One documented failure

  • not_found

    Document not found.

    not_found

Error handling

A 400 is returned: invalid_metadata : The metadata query parameter value is invalid (must be all, only, or without). A 403 is returned: - forbidden : You do not have permission to access this document.

  • forbidden : Knowledge base API access is not enabled.
  • forbidden : The API key is scoped to specific knowledge bases, and this knowledge base is not one of them. A 404 is returned: not_found : Document not found. Also returned as "Dataset not found." when the knowledge base itself does not exist.