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

List Chunks

Returns a paginated list of chunks within a document, optionally filtered by keyword or indexing status.

6 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. Obtain it from [List Documents](/en/api-reference/documents/list-documents).
pageintegeroptional
Page number.
Default:1
limitintegeroptional
Number of items per page. Server caps at `100`.
Default:20
statusarray<string>optional
Filter chunks by indexing status, e.g. `completed`, `indexing`, `error`.
keywordstringoptional
Search keyword.

4 status codes
200List of chunks.
dataarray<object>optional
List of chunks.
doc_formstringoptional
Document chunking mode used by this document.
has_morebooleanoptional
Whether more items exist on the next page.
limitintegeroptional
Number of items per page.
pageintegeroptional
Current page number.
totalintegeroptional
Total number of matching chunks.
400`provider_not_initialize` : The knowledge base uses high-quality indexing but its embedding model is missing or misconfigured.

One documented failure

  • provider_not_initialize

    No Embedding Model available. Please configure a valid provider in the Settings -> Model Provider.

    provider_not_initialize

403- `forbidden` : Dataset 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

    Dataset api access is not enabled.

    forbidden (api access)

404- `not_found` : Dataset not found. - `not_found` : Document not found.

One documented failure

  • not_found

    Dataset not found.

    not_found

Error handling

A 400 is returned: provider_not_initialize : The knowledge base uses high-quality indexing but its embedding model is missing or misconfigured. A 403 is returned: - forbidden : Dataset 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 : Dataset not found.
  • not_found : Document not found.