Skip to main content

Update Chunk

Update the content of a single chunk.

Prerequisites

Configure the endpoint and authentication first. See API overview and Authentication.

Endpoint

POST /api/v1/indices/rag/index/chunk/update Update the content of a specified chunk.
Chunk content must be between 10 and 6000 characters.

Request body

FieldRequiredTypeDescription
pipelineIdYesstringKnowledge base ID, the data.id returned by the createIndex API.
chunkIdYesstringID of the chunk to update. Obtain it from the listChunks API, using the node.metadata._id field in the response.
dataIdYesstringFile ID, the fileId returned by the addFile API; also available from node.metadata.doc_id of the listChunks API.
contentYesstringChunk content, 10 to 6000 characters, and must not exceed the maximum segment length set when the knowledge base was created.
titleNostringChunk title, 0 to 50 characters. Pass an empty string to clear the title; omit this parameter to keep the original title unchanged.
isDisplayedChunkContentYesbooleanWhether the chunk participates in knowledge base retrieval. true: participates in retrieval; false: does not participate in retrieval.

Request example

curl -X POST "$BASE_URL/api/v1/indices/rag/index/chunk/update" \
  -H "Authorization: Bearer $BAILIAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "pipelineId": "your_index_id",
    "chunkId": "chunk_abc123",
    "dataId": "data_xyz789",
    "content": "更新后的切片内容,长度需在 10-6000 字符之间。",
    "title": "更新后的标题",
    "isDisplayedChunkContent": true
  }'
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,
  "request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

Response fields

FieldTypeDescription
codestringResponse code. Success on success.
status_codeintegerHTTP status code.
request_idstringUnique request identifier. Provide this ID when troubleshooting.
successbooleanWhether the operation succeeded.
messagestringResponse message. success on success.
statusstringRequest status: SUCCESS or FAILED.

Error codes

HTTP status codeError codeMessageDescription
400Index.InvalidParameterRequired parameter missing or invalid.Invalid request parameters.
401InvalidApiKeyInvalid API-key provided.Authentication failed. The API key is invalid or missing.
Managed Agent API
Flow Agent API
Sandbox API
RAG API
Long-term Memory
ParseX API
Security API
Framework Integration