修改知识库
接口说明
修改知识库名称或描述。请求需要在 If-Match 中提交当前 resourceRevision;修改保存后直接返回更新后的知识库记录。
接口信息
| 字段 | 值 |
|---|---|
| 方法 | PATCH |
| 路径 | /openapi/v2/knowledge-bases/{knowledgeBaseId} |
| Operation ID | updateKnowledgeBase |
| 鉴权 | Bearer OpenAPI key |
入参
| 名称 | 位置 | 必填 | 类型 | 示例 | 说明 |
|---|---|---|---|---|---|
knowledgeBaseId | path | 是 | string | knowledge-base-11111111-1111-4111-8111-111111111111 | 知识库 API 返回的知识库标识。 |
If-Match | header | 是 | string | "1" | API 返回的当前 resourceRevision。如果读取后资源又被修改,请求会返回冲突,避免覆盖较新的修改。 |
请求体
application/json
| 字段 | 必填 | 类型 | 示例 | 说明 |
|---|---|---|---|---|
name | 否 | string | Product handbook | 资源名称,最多 255 个 UTF-8 字节。 |
description | 否 | string | null | Current product guidance. | 更新后的描述,最多 16384 个 UTF-8 字节;传入 null 可以清空描述。 |
请求示例
bash
curl -X PATCH "https://openapi.example.com/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111" \
-H "Authorization: Bearer <openapi-key>" \
-H "If-Match: \"1\"" \
-H "Content-Type: application/json" \
--data '{
"name": "Product handbook",
"description": "Current product guidance."
}'成功响应
200
返回更新后的知识库记录。
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
knowledgeBase | 是 | object | 知识库记录。 |
成功响应示例
json
{
"knowledgeBase": {
"knowledgeBaseId": "knowledge-base-11111111-1111-4111-8111-111111111111",
"name": "Product Docs",
"description": "Product documentation",
"activeContentRevision": 1,
"resourceRevision": 1,
"createdAt": "2026-06-17T00:00:00.000Z",
"updatedAt": "2026-06-17T00:00:00.000Z"
}
}错误码
下表列出这个接口已声明的全部错误响应。
| HTTP 状态 | 错误码 | 说明 |
|---|---|---|
| 401 | UNAUTHORIZED | Bearer API key 缺失、格式错误、未知、已撤销或已删除。 |
| 404 | NOT_FOUND | 请求的资源不存在。 |
| 409 | CONFLICT | 请求与资源当前状态冲突。 |
| 413 | PAYLOAD_TOO_LARGE | 请求体或待读取文件超过当前接口允许的大小。 |
| 422 | VALIDATION_ERROR | 请求未通过校验。 |
| 429 | RATE_LIMITED | 请求超过当前配置的速率限制。 |
| 500 | INTERNAL_ERROR | API 遇到内部错误。 |
| 503 | DATABASE_REPOSITORY_UNAVAILABLE | 当前接口所需的数据暂时不可用。 |