Import semantic entries¶
Batch import semantic entries into a knowledge base without semantic entries.
POST $CLOUDSIGMA_API_BASE/semantic-models/{model_id}/import
Before you call this API¶
Configure the regional API endpoint and authentication, and select the target workspace.
First query the knowledge base list to obtain the knowledge base ID, and confirm that the target knowledge base has no semantic entries.
Set the operation-specific values used in the request:
$MODEL_ID: Receives the knowledge base ID of the imported entry.
Request¶
curl -X POST "$CLOUDSIGMA_API_BASE/semantic-models/$MODEL_ID/import" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"entries": [
{
"kind": "metric",
"key": "total_rows",
"spec": {
"expr": "COUNT(*)"
}
}
]
}'
Path parameters
Parameters |
Type |
Description |
|---|---|---|
|
integer |
The knowledge base ID to receive the imported entry. |
Request body
The request body is an array of entries; each contains kind, key, optionally tables, and spec.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
object[] |
Yes |
The entry to import; cannot be empty. The target knowledge base cannot already have semantic entries. |
|
string |
Yes |
Entry type; it determines the structure of |
|
string |
Yes |
A stable reference key within the knowledge base; cannot be repeated in the same request. |
|
array[string] |
No |
The name of the association table. |
|
object |
Yes |
A type-specific configuration object. Its fields and constraints are the same as Create semantic entry. |
In field paths, [] means each item in an array. For example, entries[].kind is the kind field of each item in entries.
Successful response¶
Returns 200 on success. imported is the number of writes this time; then list the entries and run verification, not just checking the HTTP status.
{
"code": "OK",
"msg": "OK",
"data": {
"imported": 1,
"model_id": 401
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
integer |
The number of entries imported and written this time. |
|
integer |
Receives the imported knowledge base ID. |
Error response¶
{
"code": "ErrConflict",
"msg": "duplicate semantic entry key",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
|
Resubmit the entire batch after correcting each entry; if the target already has entries, use a knowledge base without semantic entries instead. |
|
|
The API Key is invalid or has expired. |
Check API Key. |
|
|
The caller does not have import permissions. |
Check workspace and object authorization. |
|
|
The knowledge base does not exist or is not visible. |
Reconfirm |
|
|
There is a duplicate |
Resubmit after removing duplicates. |
|
|
The service failed to import the entry. |
Keep the desensitized response information and try again. |
Follow-up operations¶
Query semantic entries and Verify semantic entries to confirm the import results.