Skip to main content
post/datasets/{dataset_id}/document/create-by-text
Request example
Response
post/datasets/{dataset_id}/document/create-by-text

Authorization

Authorizationstringheaderrequired#

Every request authenticates with an API key: Authorization: Bearer {API_KEY}. App endpoints take an app API key; knowledge endpoints take a knowledge base API key (Get Started).

Keep keys server-side; never embed them in client code. Requests with a missing or invalid key fail with HTTP 401 (unauthorized).

Path parameters

dataset_idstringrequired#
Knowledge base ID, from List Knowledge Bases. For a scoped key, copy the ID from the Dify URL.

Body

application/json
doc_formenum<string>#
text_model for standard text chunking, hierarchical_model for parent-child chunk structure, qa_model for question-answer pair extraction.

Default: "text_model"

Options:text_modelhierarchical_modelqa_model
doc_languagestring#
Language of the document for processing optimization.

Default: "English"

embedding_modelstring#
Embedding model name. Use the model field from Get Available Models with model_type=text-embedding.
embedding_model_providerstring#
Embedding model provider. Use the provider field from Get Available Models with model_type=text-embedding.
indexing_techniqueenum<string>#
Required when adding the first document to a knowledge base. Subsequent documents inherit the knowledge base's indexing technique if omitted. high_quality uses embedding models for precise search; economy uses keyword-based indexing.
Options:high_qualityeconomy
namestringrequired#
Document name.
original_document_idstring#
Original document ID for versioning. Get it from List Documents.
process_ruleobject#
Processing rules for chunking.
retrieval_modelobject#
textstringrequired#
Document text content.

Responses

application/json
Document created successfully.
batchstring#
Batch ID for tracking indexing progress.
documentobject#