/datasets/{dataset_id}/document/create-by-textCreate a knowledge base document from text
Creates a document in a knowledge base from raw text. Provide name and text; when adding the first document, also provide indexing_technique, and doc_form defaults to text_model. Indexing runs asynchronously, so use the returned batch ID with GET /datasets/{dataset_id}/documents/{batch}/indexing-status to track progress.
- IdempotentThe SDK sends
Idempotency-Key, so a retried request is only applied once.
Document creation settings and raw text content. name and text are required; provide indexing_technique when adding the first document to a knowledge base.
2 documented failures
invalid_paramindexing_technique is required.
invalid_param (indexing_technique)
provider_not_initializeNo valid model provider credentials found. Please go to Settings -> Model Provider to complete your provider credentials.
provider_not_initialize
One documented failure
forbiddenDataset api access is not enabled.
forbidden (api access)
One documented failure
not_foundDataset not found.
not_found
One documented failure
service_unavailableUnable to verify vector space usage right now. Please try again later.
service_unavailable
A 400 is returned when the first document lacks indexing_technique, doc_form is invalid, or the workspace has no configured default embedding model. A 403 is returned when knowledge base API access is disabled, a subscription limit or request rate limit is reached, or the API key is not scoped to the specified knowledge base; a 404 is returned when the knowledge base does not exist. A 503 can occur on the Dify Cloud Sandbox plan when vector space usage cannot be verified; retry the request. The dataset_id path parameter must identify an accessible knowledge base; name and text are required, and doc_form, indexing_technique, process_rule.mode, and retrieval_model.search_method must use the values allowed by their schemas.