Documents

Create Document by File

Changed on

Creates a document in a knowledge base from an uploaded file. Common formats such as PDF, TXT, and DOCX are supported. Indexing runs asynchronously; track it with the returned batch ID via Get Document Indexing Status.

post/datasets/{dataset_id}/document/create-by-file

Request

  • Base URL
    https://api.dify.ai/v1
  • URL
    https://api.dify.ai/v1/datasets/{dataset_id}/document/create-by-file
  • Auth
    HTTP bearer

Path parameters

dataset_idstring uuid required

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

Request body multipart/form-data

datastring

JSON string containing configuration. Accepts the same fields as Create Document by Text (indexing_technique, doc_form, doc_language, process_rule, retrieval_model, embedding_model, embedding_model_provider) except name and text.

filestring binary required

File to upload, capped at 15 MB by default.

Self-hosted deployments adjust the limit with the UPLOAD_FILE_SIZE_LIMIT environment variable. On Dify Cloud, Professional and Team plans raise the cap to 50 MB.

Example request

{
  "data": "{\"indexing_technique\":\"high_quality\",\"doc_form\":\"text_model\",\"doc_language\":\"English\",\"process_rule\":{\"mode\":\"automatic\"}}"
}

Response

Document created successfully.

batchstring

Batch ID for tracking indexing progress.

Changes