Delete Document
Delete a document and all of its chunks from a Knowledge Base.
Prerequisites
Configure the endpoint and authentication first. See API overview and Authentication.
Endpoint
POST /api/v1/indices/rag/index/delete_file
Delete a document and all of its chunks from a specified knowledge base.
WarningThis operation is irreversible. This endpoint uses snake_case parameters — index_id and doc_ids — unlike the camelCase (indexId) used by other endpoints. Sending IndexId or indexId returns Index.InvalidParameter.
When a parameter is missing, the server returns Required parameter(IndexId) missing or invalid. The IndexId in that message is the server's internal field name, not the request parameter name — still send index_id.
Request body
| Field | Required | Type | Description |
|---|---|---|---|
index_id | Yes | string | Knowledge base ID. |
doc_ids | Yes | array<string> | List of document IDs to delete. |
Request example
curl -X POST "$BASE_URL/api/v1/indices/rag/index/delete_file" \
-H "Authorization: Bearer $BAILIAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"index_id": "your_index_id",
"doc_ids": ["file_xxx"]
}'
BASE_URL is https://{workspace_id}.cn-beijing.maas.aliyuncs.com ({workspace_id} is the workspace ID), and BAILIAN_API_KEY is your Alibaba Cloud Model Studio API key.
Response example
Returns 200 on success.
{
"code": "Success",
"status_code": 200,
"data": {
"deleted": []
},
"success": true,
"message": "success",
"request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"status": "SUCCESS"
}
Response fields
| Field | Type | Description |
|---|---|---|
code | string | Response code. Success on success. |
status_code | integer | HTTP status code. |
request_id | string | Unique request identifier. Provide this ID when troubleshooting. |
data | object | Business data. Sub-field: deleted (array<string>, list of deleted document IDs). |
success | boolean | Whether the operation succeeded. |
message | string | Response message. success on success. |
status | string | Request status: SUCCESS or FAILED. |
Error codes
| HTTP status code | Error code | Message | Description |
|---|---|---|---|
| 400 | Index.InvalidParameter | Required parameter missing or invalid. | Invalid request parameters. |
| 401 | InvalidApiKey | Invalid API-key provided. | Authentication failed. The API key is invalid or missing. |