Update knowledge base¶
Update knowledge base metadata. Each successful update increments version by one; this interface does not perform file parsing or indexing.
PATCH https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/knowledge-bases/{knowledge_base_id}
Before you call¶
First Query the knowledge base details to confirm the current metadata and version. Prepare a personal access token and target workspace ID that has access to the target workspace.
The example below uses:
$AI_STUDIO_API_KEY: The actual personal access token, passed through theX-API-KeyHeader.$WORKSPACE_ID: Target workspace ID, passed through theX-Workspace-IDHeader and also asworkspace_idin the path.$KNOWLEDGE_BASE_ID: ID of the knowledge base to be updated.
Request example¶
curl -X PATCH "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/knowledge-bases/$KNOWLEDGE_BASE_ID" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"name": "产品文档(已审核)",
"status": "active",
"index_status": "ready",
"tags": ["产品", "文档", "已审核"]
}'
Path parameters¶
Parameters |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
Yes |
Current workspace ID, must be consistent with |
|
string |
Yes |
The ID of the knowledge base to update. |
Request body¶
All fields are optional; only the fields provided in the request are updated.
Parameters |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
No |
New name, length cannot exceed 128. |
|
string |
No |
New description, length cannot exceed 4096. |
|
string |
No |
|
|
string |
No |
|
|
object[] |
No |
Replace all associated assets. Each must provide |
|
string |
No |
Default to retrieve configuration reference. |
|
string[] |
No |
Replace all tags. |
|
string |
No |
Update owner user ID. |
|
string |
No |
|
|
string |
No |
|
|
string |
No |
The most recent index time, in RFC 3339 format. |
|
string |
No |
Recent index error message, length cannot exceed 4096. |
|
object |
No |
Replace string key-value label. |
|
object |
No |
Replace string key value annotation. |
|
object |
No |
Replaces extended metadata; must not contain keys, provider runtime information, or session references. |
[] after a type denotes an array. [] in a field path denotes each item in an array.
Successful response¶
Returns 200 on success. data is the updated knowledge base metadata, and data.version is increased by 1 than before the update.
{
"code": 0,
"data": {
"id": "kb_01",
"workspace_id": "ws_01",
"name": "产品文档(已审核)",
"status": "active",
"source_type": "catalog_resource",
"visibility": "workspace",
"index_status": "ready",
"version": 2,
"updated_by": "user_01",
"updated_at": "2026-08-18T02:00:00Z"
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
integer |
|
|
string |
Knowledge base ID. |
|
string |
ID of the workspace to which it belongs. |
|
string |
The updated name and description; will not be returned if the description is not set. |
|
string |
The updated name and description; will not be returned if the description is not set. |
|
string |
Updated status and source type. |
|
string |
Updated status and source type. |
|
object[] |
Associated assets; not returned if not set. |
|
string |
Default retrieval configuration reference; does not return if not set. |
|
string[] |
Label; does not return if not set. |
|
string |
Owner user ID; not returned if not set. |
|
string |
Visible range and index status. |
|
string |
Visible range and index status. |
|
string |
Recent index time and error message; not returned if not set. |
|
string |
Recent index time and error message; not returned if not set. |
|
integer |
The updated resource version. |
|
object |
Extended tags, comments, and metadata; not returned if not set. |
|
object |
Extended tags, comments, and metadata; not returned if not set. |
|
object |
Extended tags, comments, and metadata; not returned if not set. |
|
string |
Creator and last updater ID; not returned if not set. |
|
string |
Creator and last updater ID; not returned if not set. |
|
string |
Creation and last update times, in RFC 3339 format. |
|
string |
Creation and last update times, in RFC 3339 format. |
[] after a type denotes an array. [] in a field path denotes each item in an array.
Error response¶
{
"code": 2,
"message": "invalid knowledge base metadata"
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
The request body cannot be parsed, the field value or asset reference does not meet the requirements, or the metadata contains sensitive references that are not allowed. |
Check request fields and asset references; do not pass in credentials or session information. |
|
|
Lack of valid identity credentials. |
Check API Key. |
|
|
The knowledge base does not exist in the current workspace. |
Check out |
|
|
The knowledge base service is temporarily unavailable. |
Try again later. |
Follow-up operations¶
Call Query knowledge base details to confirm the updated metadata and version.