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.

HTTP
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

Shell
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

workspace_id

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

name

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.

id

string

No

knowledge base ID. Generated by the server if not provided.

description

string

No

Note that after removing the leading and trailing blanks, there are at most 4096 UTF-8 bytes.

status

string

No

Status: draft, active, disabled, or archived. Draft when not provided.

source_type

string

No

Source type: manual, catalog_resource, file_collection, external_drive, or connector_export. Manual when not provided.

catalog_asset_refs

array of object

No

The associated Catalog asset. For member description, see Associated Asset Field.

default_retrieval_profile_ref

string

No

Configuration references are retrieved by default.

tags

array of string

No

label.

owner_user_id

string

No

Resource owner ID. If not provided, the current user ID is used.

visibility

string

No

Visible scope: private or workspace. Private when not provided.

index_status

string

No

Index status: empty, indexing, ready, or failed. Empty when not provided.

last_indexed_at

string

No

The most recent index time, in RFC 3339 format.

last_index_error

string

No

The most recent index error information, after removing leading and trailing blanks, is at most 4096 UTF-8 bytes.

labels

object

No

String key-value label.

annotations

object

No

String key value annotation.

metadata

object

No

Extended metadata. Cannot contain keys, provider runtime information, or session references.

catalog_asset_refs[].type

string

Yes

Asset type.

catalog_asset_refs[].id

string

Conditional

Asset ID. Required if uri is not filled in.

catalog_asset_refs[].uri

string

Conditional

Asset URI. Required if id is not filled in.

catalog_asset_refs[].version

string

No

Asset version.

catalog_asset_refs[].role

string

No

Asset-related roles.

catalog_asset_refs[].config

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

JSON
{
  "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

code

integer

success code.

data

object

The data returned by this operation.

data.id

string

knowledge base ID.

data.workspace_id

string

The workspace ID to which it belongs.

data.name

string

knowledge base name and description.

data.description

string

knowledge base name and description.

data.status

string

knowledge base status. The values are draft, active, disabled, archived

data.source_type

string

knowledge base source type. The values are manual, catalog_resource, file_collection, external_drive, connector_export

data.catalog_asset_refs

array of object

The associated Catalog asset. For member description, see Associated Asset Field.

data.catalog_asset_refs[].type

string

type.

data.catalog_asset_refs[].id

string

ID of the current object.

data.catalog_asset_refs[].uri

string

Resource URI.

data.catalog_asset_refs[].version

string

The current resource version.

data.catalog_asset_refs[].role

string

Associated roles.

data.catalog_asset_refs[].config

object

Configuration object objects allow extended keys.

data.default_retrieval_profile_ref

string

Configuration references are retrieved by default.

data.tags

array of string

label.

data.owner_user_id

string

Owner user ID.

data.visibility

string

Visible range. The values are private, workspace

data.index_status

string

Index status. The values are empty, indexing, ready, failed

data.last_indexed_at

string or null

Last index time and error message.

data.last_index_error

string

Last index time and error message.

data.version

integer

Resource version, 1 when created.

data.labels

object

String key-value labels and annotation objects allow extended keys.

data.annotations

object

String key-value labels and annotation objects allow extended keys.

data.metadata

object

Extended metadata objects allow extended keys.

data.created_by

string

Creator and last updated ID.

data.updated_by

string

Creator and last updated ID.

data.created_at

string

Creation and last update times, in RFC 3339 format.

data.updated_at

string

Creation and last update times, in RFC 3339 format.

Error response

JSON
{
  "code": 2,
  "message": "invalid knowledge base metadata"
}

Common HTTP errors

HTTP status

Error code

Common cause

Recommended action

400

2

Invalid request field, workspace, or operation precondition.

Fix the request parameters and submit again.

401

6

Missing or invalid authentication credentials.

Check the credential type, expiration, and authentication header.

403

5

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

3

The target object or required reference was not found.

Verify the object identifier, workspace, and current status.

409

4

Conflict in resource state, request payload, or concurrent modification.

Re-read the current state and version, then handle according to the latest result.

503

15

A business, runtime, or authorization dependency is temporarily unavailable.

After the dependency recovers, check existing results first instead of blindly repeating writes.

Last updated on