POST
/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}/child_chunksCreate Child Chunk
Create a child chunk under a parent chunk. Intended for documents that use the parent-child (hierarchical_model) chunking mode.
- 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
Parent chunk ID. Obtain it from [List Chunks](/en/api-reference/chunks/list-chunks).
contentstringrequired
Child chunk text content.
200Child chunk created successfully.
dataobjectoptional
400- `provider_not_initialize` : The knowledge base uses high-quality indexing but its embedding model is missing or misconfigured.
- `invalid_param` : Indexing the child chunk in the vector store failed; the message carries the underlying vector-store error.
2 documented failures
invalid_paramVector store operation failed: [Errno 111] Connection refused
invalid_param
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` : To unlock this feature and elevate your Dify experience, please upgrade to a paid plan.
- `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: Indexing the child chunk in the vector store failed; the message carries the underlying vector-store error. 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: To unlock this feature and elevate your Dify experience, please upgrade to a paid plan.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.