Create agent knowledge base metadata¶
Creates knowledge base metadata that the agent can reference and does not perform file parsing, indexing, or retrieval.
To create a knowledge base in the resource center to which files and data tables can be added, use Create an empty knowledge base.
POST $CLOUDSIGMA_API_BASE/workspaces/{workspace_id}/knowledge-bases
Before you call¶
Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. Prepare a personal access token and target workspace ID that can access the target workspace.
Request body¶
curl -X POST "$CLOUDSIGMA_API_BASE/workspaces/$WORKSPACE_ID/knowledge-bases" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"name": "产品文档",
"description": "已审核的产品资料",
"status": "active",
"source_type": "catalog_resource",
"catalog_asset_refs": [
{
"type": "catalog",
"id": "<CATALOG_ID>",
"role": "source"
}
],
"visibility": "workspace",
"index_status": "ready",
"tags": ["产品", "文档"]
}'
catalog_asset_refs[].uri cannot contain credentials or sensitive query parameters.
catalog_asset_refs[].config and metadata cannot contain running, session references to keys or providers.
The workspace is taken from the request path, and the current user is taken from the calling identity. There is no need to pass it in the request body.
Path parameters
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
The current workspace ID must be consistent with X-Workspace-ID. |
Request body
labels, annotations and config in asset references must be objects when created, the root value null is rejected. Single value for label, annotation allowed string or null. The name is capped at 128 UTF-8 bytes, and the description and most recent index error are each capped at 4096 UTF-8 bytes.
Omitting metadata when creating or setting it to null will generate the default runtime_tool_refs. When metadata is provided but the key is not present, 13 system tool references are also supplemented. Explicitly set to an empty array or null to retain this value. The deactivated compute_result_table tool cannot be referenced.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
knowledge base name. It must be non-empty after removing the leading and trailing blanks, and the UTF-8 encoding cannot exceed 128 bytes. |
|
string |
No |
knowledge base ID. Generated by the server if not provided. |
|
string |
No |
Note that after removing the leading and trailing blanks, there are at most 4096 UTF-8 bytes. |
|
string |
No |
Status: draft, active, disabled, or archived. Draft when not provided. |
|
string |
No |
Source type: manual, catalog_resource, file_collection, external_drive, or connector_export. Manual when not provided. |
|
array of object |
No |
The associated Catalog asset. For member description, see Associated Asset Field. |
|
string |
No |
Configuration references are retrieved by default. |
|
array of string |
No |
label. |
|
string |
No |
Resource owner ID. If not provided, the current user ID is used. |
|
string |
No |
Visible scope: private or workspace. Private when not provided. |
|
string |
No |
Index status: empty, indexing, ready, or failed. Empty when not provided. |
|
string |
No |
The most recent index time, in RFC 3339 format. |
|
string |
No |
The most recent index error information, after removing leading and trailing blanks, is at most 4096 UTF-8 bytes. |
|
object |
No |
String key-value label. |
|
object |
No |
String key value annotation. |
|
object |
No |
Extended metadata. Cannot contain keys, provider runtime information, or session references. |
|
string |
Yes |
Asset type. |
|
string |
Conditional |
Asset ID. Required if uri is not filled in. |
|
string |
Conditional |
Asset URI. Required if id is not filled in. |
|
string |
No |
Asset version. |
|
string |
No |
Asset-related roles. |
|
object |
No |
Asset Allocation. |
The name can contain /, for example 产品文档/安装指南. / is saved as the name content. When querying and updating knowledge base metadata, use the returned data.id as knowledge_base_id. The associated Catalog asset is specified by catalog_asset_refs.
Each item in catalog_asset_refs describes an associated asset. type is a required field, fill in at least one of id and uri.
Successful response¶
{
"code": 0,
"data": {
"id": "kb_01",
"workspace_id": "ws_01",
"name": "产品文档",
"description": "已审核的产品资料",
"status": "active",
"source_type": "catalog_resource",
"catalog_asset_refs": [
{
"type": "catalog",
"id": "cat_01",
"role": "source"
}
],
"tags": [
"产品",
"文档"
],
"owner_user_id": "user_01",
"visibility": "workspace",
"index_status": "ready",
"version": 1,
"created_by": "user_01",
"updated_by": "user_01",
"created_at": "2026-08-18T01:00:00Z",
"updated_at": "2026-08-18T01:00:00Z",
"metadata": {
"runtime_tool_refs": [
{
"id": "find_rag_files",
"workspace_id": "system",
"kind": "tool"
},
{
"id": "search_rag_chunks",
"workspace_id": "system",
"kind": "tool"
},
{
"id": "search_visual_image",
"workspace_id": "system",
"kind": "tool"
},
{
"id": "read_parsed_markdown",
"workspace_id": "system",
"kind": "tool"
},
{
"id": "search_parsed_markdown",
"workspace_id": "system",
"kind": "tool"
},
{
"id": "describe_schema",
"workspace_id": "system",
"kind": "tool"
},
{
"id": "query_sql",
"workspace_id": "system",
"kind": "tool"
},
{
"id": "upsert_knowledge_table",
"workspace_id": "system",
"kind": "tool"
},
{
"id": "select_final_sources",
"workspace_id": "system",
"kind": "tool"
},
{
"id": "read_artifact",
"workspace_id": "system",
"kind": "tool"
},
{
"id": "read_artifact_page",
"workspace_id": "system",
"kind": "tool"
},
{
"id": "write_file",
"workspace_id": "system",
"kind": "tool"
},
{
"id": "read_file",
"workspace_id": "system",
"kind": "tool"
}
]
}
}
}
Field |
Type |
Description |
|---|---|---|
|
integer |
success code. |
|
object |
The data returned by this operation. |
|
string |
knowledge base ID. |
|
string |
The workspace ID to which it belongs. |
|
string |
knowledge base name and description. |
|
string |
knowledge base name and description. |
|
string |
knowledge base status. The values are |
|
string |
knowledge base source type. The values are |
|
array of object |
The associated Catalog asset. For member description, see Associated Asset Field. |
|
string |
type. |
|
string |
ID of the current object. |
|
string |
Resource URI. |
|
string |
The current resource version. |
|
string |
Associated roles. |
|
object |
Configuration object objects allow extended keys. |
|
string |
Configuration references are retrieved by default. |
|
array of string |
label. |
|
string |
Owner user ID. |
|
string |
Visible range. The values are |
|
string |
Index status. The values are |
|
string or null |
Last index time and error message. |
|
string |
Last index time and error message. |
|
integer |
Resource version, 1 when created. |
|
object |
String key-value labels and annotation objects allow extended keys. |
|
object |
String key-value labels and annotation objects allow extended keys. |
|
object |
Extended metadata objects allow extended keys. |
|
string |
Creator and last updated ID. |
|
string |
Creator and last updated ID. |
|
string |
Creation and last update times, in RFC 3339 format. |
|
string |
Creation and last update times, in RFC 3339 format. |
Error response¶
{
"code": 2,
"message": "invalid knowledge base metadata"
}
Common HTTP errors¶
HTTP status |
Error code |
Common cause |
Recommended action |
|---|---|---|---|
400 |
|
Invalid request field, workspace, or operation precondition. |
Fix the request parameters and submit again. |
401 |
|
Missing or invalid authentication credentials. |
Check the credential type, expiration, and authentication header. |
403 |
|
The current identity or active role does not have permission for this operation. |
Use an authorized identity or contact an administrator to grant access. |
404 |
|
The target object or required reference was not found. |
Verify the object identifier, workspace, and current status. |
409 |
|
Conflict in resource state, request payload, or concurrent modification. |
Re-read the current state and version, then handle according to the latest result. |
503 |
|
A business, runtime, or authorization dependency is temporarily unavailable. |
After the dependency recovers, check existing results first instead of blindly repeating writes. |