POST/datasets/{dataset_id}/documents/metadata

Update Document Metadata in Batch

Update metadata values for multiple documents in a single request.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

1 parameter · 1 body field
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).
operation_dataarray<object>required
Document metadata update operations, one entry per document.

3 status codes
200Document metadata updated successfully.
resultstringoptional
Operation result.
403- `forbidden` : Dataset 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.

One documented failure

  • forbidden

    Dataset api access is not enabled.

    forbidden (api access)

404- `not_found` : Knowledge base not found. - `not_found` : A document referenced in `operation_data` does not exist in this knowledge base. - `not_found` : A metadata field referenced in `metadata_list` does not exist in this knowledge base.

One documented failure

  • not_found

    Dataset not found.

    not_found (knowledge base)

Error handling

A 403 is returned: - forbidden : Dataset 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 : Knowledge base not found.
  • not_found : A document referenced in operation_data does not exist in this knowledge base.
  • not_found : A metadata field referenced in metadata_list does not exist in this knowledge base.