Create a knowledge base and add data sources

Create a knowledge base and create processing tasks for the initial data source. The content cannot be retrieved until processing is complete.

HTTP
POST $CLOUDSIGMA_API_BASE/semantic-models/create-with-sources

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. Confirm the source first: Catalog tables, Catalog files, and batch selections can only reference data already in the Catalog. For local files, first obtain the file ID through Upload local file. Prepare a personal access token and target workspace ID that has access rights to the target workspace and permission to create knowledge base.

Request body

Replace $CLOUDSIGMA_API_KEY, $WORKSPACE_ID in the example with actual values.

Shell
curl -X POST "$CLOUDSIGMA_API_BASE/semantic-models/create-with-sources" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "<KNOWLEDGE_BASE_NAME>",
  "sources": [
    {
      "source_type": "catalog_table",
      "table_id": 123
    }
  ]
}'

When adding sources directly, fields are provided by source type:

Source type

Required fields

catalog_table

table_id

catalog_file

file_id

local_file

Upload the returned file_id, original file_name

source_selections can only be selected within the Database or Volume range of the Catalog, and data sources outside the Catalog cannot be passed in.

Field

Type

Required

Description

sources

array of object

Yes

The list of directly added data source objects contains at least 1 items.

source_type

string

No

Source type. Values: local_file, catalog_file, catalog_table.

file_name

string

No

File name.

upload_kind

string

No

Upload method.

table_config

string

No

Create table configuration JSON text.

file_id

string

No

File ID.

table_id

integer

No

Table ID.

content_base64

string

No

Base64 encoded content of the local file.

kind

string

No

Selection range: database_tables (table in database) or volume_files (file in volume).

database_id

integer

No

Database ID.

volume_id

integer

No

Volume ID. The associated volume ID.

all_selected

boolean

No

Whether to select all.

selected_table_ids

integer (array of integers) or null

No

Selected table ID.

excluded_table_ids

integer (array of integers) or null

No

Excluded table ID.

selected_file_ids

array of string or null

No

Selected file ID.

excluded_file_ids

array of string or null

No

Excluded file IDs.

filters

object

No

Filter criteria.

filters.table_name

string

No

Table name.

filters.file_name

string

No

File name.

filters.file_ext

array of string or null

No

File extension.

table_name

string

No

Table name.

file_ext

array of string or null

No

File extension.

parents

array of string or null

No

parent relationship.

path

array of string or null

No

path.

id

string

No

logo.

image_vector_table

string

No

Image vector table.

image_embedding_model

string

No

Image vector model.

image_embedding_backend_id

string

No

Image vector backend ID.

image_embedding_dimension

integer

No

Image vector dimensions.

image_preprocess_version

string

No

Image preprocessing version.

image_distance_metric

string

No

Image distance metric.

image_scope

string

No

Image range.

status

string

No

status.

Successful response

JSON
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "model": {
      "id": 401,
      "name": "product_docs",
      "tables": null,
      "created_at": 1735632000,
      "updated_at": 1735632000,
      "source_counts": {
        "files": 0,
        "tables": 0,
        "total": 0
      }
    },
    "data_domain": {
      "model_id": 401,
      "catalog_id": 10,
      "database_id": 20,
      "raw_volume_id": 30,
      "processed_volume_id": 31,
      "ensure_status": "ready",
      "last_checked_at": 1735632000
    },
    "sources": [
      {
        "row_id": "src_01",
        "source_type": "table",
        "model_id": 401,
        "resource_id": "123",
        "display_name": null,
        "path": [],
        "db_name": null,
        "table_name": null,
        "size_bytes": null,
        "row_count": null,
        "ingest_status": "pending",
        "enabled": null,
        "expires_at": null,
        "expired": false,
        "effective_enabled": true,
        "force_enabled_after_expiry": false,
        "updated_at": null,
        "error": null
      }
    ],
    "jobs": [
      {
        "job_id": "job_01",
        "source_id": "src_01",
        "model_id": 401,
        "job_type": "load",
        "job_status": "pending",
        "idempotency_key": "idem_01",
        "retry_count": 0
      }
    ]
  }
}

Field

Type

Description

data.model

object

Create a snapshot of the new knowledge base.

data.model.id

integer

logo.

data.model.name

string

Name.

data.model.description

string

Description.

data.model.tables

array of object

List of data table objects associated with knowledge base.

data.model.files

array of object

List of file objects associated with the knowledge base.

data.model.created_at

integer

Creation time.

data.model.updated_at

integer

Update time.

data.model.source_counts

object

Source quantity statistics.

data.model.source_counts.files

integer

The number of file sources must not be less than 0.

data.model.source_counts.tables

integer

The number of data table sources shall not be less than 0.

data.model.source_counts.total

integer

The sum of the number of file and table sources. Not less than 0.

data.data_domain

object

Catalog, database and file volume IDs associated with this knowledge base, as well as storage readiness status.

data.data_domain.model_id

integer

knowledge base ID.

data.data_domain.catalog_id

integer

CatalogID。

data.data_domain.database_id

integer

Database ID.

data.data_domain.raw_volume_id

integer

Original file volume ID.

data.data_domain.processed_volume_id

integer

Handles file volume IDs.

data.data_domain.ensure_status

string

Storage readiness status. Values: ready, failed, provisioning.

data.data_domain.last_ensure_error

string

Recent preparation errors. Omitted if there is no error.

data.data_domain.last_checked_at

integer

Last checked time.

data.sources

array of object

Source record created.

data.sources[].row_id

string

Record ID.

data.sources[].source_id

string

Source ID.

data.sources[].source_type

string

Source type. Value: file, table.

data.sources[].model_id

integer

Model ID.

data.sources[].resource_id

string

Resource ID.

data.sources[].source_resource_id

string

Source resource ID.

data.sources[].kb_resource_id

string

knowledge base resource ID.

data.sources[].source_file_id

string

Source file ID.

data.sources[].kb_file_id

string

knowledge base file ID.

data.sources[].source_table_id

integer

Source table ID.

data.sources[].kb_table_id

integer

knowledge base table ID.

data.sources[].display_name

string or null

Display name.

data.sources[].path

array of string

path.

data.sources[].source_path

string

Source path.

data.sources[].db_name

string or null

Database name.

data.sources[].table_name

string or null

Table name.

data.sources[].size_bytes

integer or null

size in bytes.

data.sources[].row_count

integer or null

Number of rows.

data.sources[].ingest_status

string or null

Import status. Values: removed, pending, succeeded, failed.

data.sources[].enabled

boolean or null

Whether to enable.

data.sources[].expires_at

integer or null

Expiration time.

data.sources[].expired

boolean

Has it expired?

data.sources[].effective_enabled

boolean

actual enabled status.

data.sources[].force_enabled_after_expiry

boolean

Whether to force activation after expiration.

data.sources[].tags

array of string

tag list.

data.sources[].created_by

string

Creator.

data.sources[].updated_by

string

Last updated by.

data.sources[].updated_at

integer or null

Update time.

data.sources[].error

string or null

error message.

data.sources[].governance_status

string

Management status. Value: managed, legacy_unbound.

data.sources[].legacy_origin

string

Old source information. Value: semantic_model_explicit, lineage_register.

data.jobs

array of object

Processing tasks created for the source.

data.jobs[].job_id

string

Process task ID.

data.jobs[].source_id

string

Source ID.

data.jobs[].model_id

integer

Model ID.

data.jobs[].job_type

string

Processing task type. Values: load, copy, table_clone, rag_ingest.

data.jobs[].job_status

string

Handle task status. Values: pending, queued, running, succeeded, failed.

data.jobs[].idempotency_key

string

Idempotent request key.

data.jobs[].operation_id

string

Operation ID.

data.jobs[].workflow_execution_id

string

workflow execution ID.

data.jobs[].source_file_id

string

Source file ID.

data.jobs[].kb_file_id

string

knowledge base file ID.

data.jobs[].source_table_id

integer

Source table ID.

data.jobs[].kb_table_id

integer

knowledge base table ID.

data.jobs[].retry_count

integer

Number of retries.

data.jobs[].next_retry_at

integer

Next retry time.

data.jobs[].error

string

error message.

data.jobs[].created_at

integer

Creation time.

data.jobs[].updated_at

integer

Update time.

data.jobs[].reconcile_required

boolean

Whether the processing status needs to be repaired.

Error response

JSON
{
  "code": "ErrParamInvalid",
  "msg": "Bad Request"
}

Field

Type

Description

code

string

error code.

msg

string

Error description.

Last updated on