DELETE/datasets/{dataset_id}/documents/{document_id}

Delete Document

Permanently deletes a document and all its chunks from the knowledge base.

2 parameters
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. From [List Documents](/en/api-reference/documents/list-documents).

3 status codes
204Success.
403- `archived_document_immutable` : The archived document is not editable. - `forbidden` : Knowledge base API access is not enabled. - `forbidden` : Sorry, you have reached the knowledge base request rate limit of your subscription. - `forbidden` : The API key is scoped to specific knowledge bases, and this knowledge base is not one of them.

2 documented failures

  • archived_document_immutable

    The archived document is not editable.

    archived_document_immutable

  • forbidden

    Dataset api access is not enabled.

    forbidden (api access)

404`not_found` : The document does not exist. Also returned as "Dataset not found." when the knowledge base itself does not exist.

One documented failure

  • not_found

    Document Not Exists.

    not_found

Error handling

A 403 is returned: - archived_document_immutable : The archived document is not editable.

  • forbidden : Knowledge base API access is not enabled.
  • forbidden : Sorry, you have reached the knowledge base request rate limit of your subscription.
  • 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 : The document does not exist. Also returned as "Dataset not found." when the knowledge base itself does not exist.