Use the DeleteDocuments operation to delete specified documents and all their chunks. The response data.documentDetails returns per-item results. An HTTP 200 status with code SUCCESS does not indicate that all documents were deleted successfully; you must check the status of each item (succeed or failed), and inspect failureReason for any failed items.
Prerequisites
-
An AgentStorage instance has been created and is in the
normalstate, and the instance endpoint and instance name have been obtained. -
An API Key has been created.
-
The documents to delete already exist. Deletion is irreversible.
Request parameters
|
Parameter |
Type |
Description |
|
|
string |
Knowledge base name (required) |
|
|
string |
Subspace name. Required when subspace is enabled |
|
|
list<object> |
The list of documents to delete (required). A maximum of 10 items per request by default |
|
|
string |
Document ID. Mutually exclusive with ossKey |
|
|
string |
OSS path. Mutually exclusive with docId |
Request example
When authenticating with an API Key, pass the instance name and API Key through the x-ots-instancename and x-ots-apikey request headers.
curl -X POST https://<endpoint>/DeleteDocuments \
-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",
"documents": [
{"ossKey": "oss://example-bucket/docs/manual.pdf"}
]
}'
Response
{"code":"SUCCESS","data":{"documentDetails":[{"ossKey":"oss://example-bucket/docs/manual.pdf","status":"succeed"}]},"message":"succeed"}