Use the UpdateDocument operation to update the metadata of a specified document. The document to be updated must be in the completed state. The metadata is updated by overwrite: the provided value fully replaces the existing metadata. If you want to update only one field, you must include all fields. Passing "metadata": null clears all metadata.
Prerequisites
-
An AgentStorage instance has been created and is in the
normalstate, and you have obtained the instance endpoint and instance name. -
An API Key has been created.
-
The document to be updated is in the
completedstate.
Request parameters
|
Parameter |
Type |
Description |
|
|
string |
The name of the knowledge base. Required. |
|
|
string |
The name of the subspace. Required when subspace is enabled. |
|
|
string |
The OSS path of the document. Mutually exclusive with |
|
|
string |
The document ID. Mutually exclusive with |
|
|
map |
The new metadata. Optional. If this field is omitted, the original value is retained and |
Sample request
When you use API Key authentication, pass the instance name and API Key through the x-ots-instancename and x-ots-apikey request headers.
curl -X POST https://<endpoint>/UpdateDocument \
-H "x-ots-instancename: <instance-name>" \
-H "x-ots-apikey: <your-api-key>" \
-H "Content-Type: application/json" \
-d '{
"knowledgeBaseName": "product_docs_kb",
"subspace": "default",
"ossKey": "oss://example-bucket/docs/manual.pdf",
"metadata": {"author": "Li Si", "date": "2026-02-01 12:00:00", "score": 80}
}'
Response
|
Field |
Type |
Description |
|
|
string |
The document ID. |
|
|
string |
The OSS path. |
|
|
long |
The update timestamp. |
|
|
string |
|