Update Document Metadata
Merges keys into a document’s user_metadata and returns the updated document. Unlike the other operations on this path, it takes the document ID, not a document file ID.
Send the document’s row_version as expectedRowVersion. Read the document right before updating it, and on 409 read it again and resend.
Authorization
Path parameters
…/knowledge-fs/spaces/<knowledge base ID>), and the segment after /datasets/new/ in the address bar.id from List Documents or Get Document, or document_id from Get Document by File. Not a document file ID, even though Get Document File and Delete Document File take one on this path. A document file ID answers 404.Body
application/jsonrow_version, from Get Document or List Documents, or the row_version this operation last returned. A newly active revision and enabling or disabling the document in Dify also change it, so read it right before updating. A stale value answers 409 and nothing changes.Range: >= 0
Keys to merge into user_metadata:
- A key with a value sets that key.
- A key with
nullremoves it. - Keys you leave out stay as they are.
Each key names a metadata field, in lowercase snake case. The field must already exist: create it in Dify first. The value must match the field's type: a string for string, a finite number for number, and a UTC timestamp such as 2026-12-01T00:00:00Z for time.
Reserved keys answer 400: activeRevision, contentHash, documentAssetId, documentAssetVersion, mimeType, provenance, providerItemId, sourceId, system, systemMetadata, tenantId, __knowledgeFs, and keys starting with system., provenance., or __knowledgeFs..
Responses
row_version is the value to send on the next update, and latest_task is always null in this response.revision to List Chunks and its document_asset_id to Get Document File. null while no revision is active.null while none is active.false after the document is disabled in Dify. Re-index Documents skips disabled documents.task_kind: document. Follow it with Get Document Indexing Task using its id. null when there is none, and always null in the Update Document Metadata response.providerItemId sent to Import Source Items, or the page_id of a website page.expectedRowVersion on Update Document Metadata, and as expectedRevision on Delete Document. It increases on metadata updates, when a new revision becomes active or the active revision's file is deleted, when the document's source is deleted with documents=keep, and when the document is enabled or disabled in Dify.null for uploaded files.pending (no revision active yet), ready (a revision is active), failed (the first revision failed to index and none is active), or deleting. A ready document stays ready when a later revision fails.