POST
/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}Update Chunk
Update a chunk's fields. The update re-triggers indexing for that chunk.
- IdempotentThe SDK sends
Idempotency-Key, so a retried request is only applied once.
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).
segment_idstringrequired
Chunk ID. Obtain it from [List Chunks](/en/api-reference/chunks/list-chunks).
segmentobjectrequired
Chunk data to update.
200Chunk updated successfully.
dataobjectoptional
doc_formstringoptional
Document chunking mode used by this document.
400- `provider_not_initialize` : The knowledge base uses high-quality indexing but its embedding model is missing or misconfigured.
- `invalid_param` : The chunk is indexing or disabled and cannot be updated, or index configuration is invalid.
2 documented failures
invalid_paramSegment is indexing, please try again later
invalid_param (state)
provider_not_initializeNo 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 capacity of the vector space has reached the limit of your subscription.
- `forbidden` : Sorry, you have reached the knowledge base request rate limit of your subscription.
- `forbidden` : The API key is scoped to specific knowledge bases, and this knowledge base is not one of them.
One documented failure
forbiddenDataset api access is not enabled.
forbidden (api access)
404- `not_found` : Dataset not found.
- `not_found` : Document not found.
- `not_found` : Segment not found.
One documented failure
not_foundDataset not found.
not_found
503`service_unavailable` : Vector space usage could not be verified. Returned on the Dify Cloud Sandbox plan only; retry the request later.
One documented failure
service_unavailableUnable to verify vector space usage right now. Please try again later.
service_unavailable
Error handling
A 400 is returned: - provider_not_initialize : The knowledge base uses high-quality indexing but its embedding model is missing or misconfigured.
invalid_param: The chunk is indexing or disabled and cannot be updated, or index configuration is invalid. A 403 is returned: -forbidden: Dataset api access is not enabled.forbidden: The capacity of the vector space has reached the limit of your subscription.forbidden: Sorry, you have reached the knowledge base request rate limit of your subscription.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.not_found: Segment not found. A 503 is returned:service_unavailable: Vector space usage could not be verified. Returned on the Dify Cloud Sandbox plan only; retry the request later.