Add data source

Add a data source to an existing knowledge base. Parsing and indexing of data sources is done by processing tasks.

HTTP
POST $CLOUDSIGMA_API_BASE/semantic-models/{model_id}/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. First check whether has been added to the data source and remove duplicates. When selecting in batches by database or volume, first Preview the data source to be added. Prepare a personal access token and target workspace ID that can access the target workspace.

Request body

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

Shell
curl -X POST "$CLOUDSIGMA_API_BASE/semantic-models/$MODEL_ID/sources" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
  "sources": [
    {
      "source_type": "catalog_file",
      "file_id": "<FILE_ID>"
    }
  ]
}'

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

Source type

Required fields

catalog_table

table_id

catalog_file

file_id

local_file

File ID returned by uploading local file, original file_name

Selecting by range only supports Database and Volume of Catalog. You cannot use source_selections to add data sources other than Catalog.

Parameter

Type

Required

Description

model_id

integer

Yes

Belonging knowledge base ID.

Request body

Field

Type

Required

Description

sources

array of object

Yes

List of data source objects added directly. Provide at least one item with source_selections and contain at least one item of 1.

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.

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.

Successful response

JSON
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "data_domain": {
      "model_id": 401,
      "catalog_id": 10,
      "database_id": 20,
      "raw_volume_id": 30,
      "processed_volume_id": 31,
      "ensure_status": "ready"
    },
    "sources": [
      {
        "row_id": "src_01",
        "source_type": "file",
        "model_id": 401,
        "resource_id": "file_01",
        "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.data_domain

object

Catalog, database and file volume information associated with this knowledge base, as well as storage preparation 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

Create a new processing task.

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