Documents

Updates a document by uploading a new file, then re-indexes it. This is the canonical endpoint for file-based document updates. Track progress with the returned batch ID via Get Document Indexing Status.

patch/datasets/{dataset_id}/documents/{document_id}

Request

  • Base URL
    https://api.dify.ai/v1
  • URL
    https://api.dify.ai/v1/datasets/{dataset_id}/documents/{document_id}
  • 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.

document_idstring uuid required

Document ID. From List Documents.

Request body multipart/form-data

datastring

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

filestring binary

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": "{\"doc_form\":\"text_model\",\"doc_language\":\"English\",\"process_rule\":{\"mode\":\"automatic\"}}"
}

Response

Document updated successfully.

batchstring

Batch ID for tracking indexing progress.

Changes