curl --request POST \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts/semantic-layer \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tables": [
{
"name": "orders",
"description": "Customer purchase orders",
"synonyms": ["purchases", "transactions"],
"columns": [
{
"name": "order_id",
"description": "Unique order identifier",
"columnType": "Identifier",
"isIdentifier": true
},
{
"name": "status",
"description": "Current order status",
"synonyms": ["order status", "state"],
"columnType": "ENUM"
},
{
"name": "amount",
"description": "Total order amount in USD",
"columnType": "Number"
}
]
}
],
"feedback": "This datamart covers e-commerce sales data. All amounts are in USD."
}'
{
"id": "sales-analytics"
}
curl --request POST \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts/semantic-layer \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tables": [
{
"name": "orders",
"description": "Customer purchase orders",
"synonyms": ["purchases", "transactions"],
"columns": [
{
"name": "order_id",
"description": "Unique order identifier",
"columnType": "Identifier",
"isIdentifier": true
},
{
"name": "status",
"description": "Current order status",
"synonyms": ["order status", "state"],
"columnType": "ENUM"
},
{
"name": "amount",
"description": "Total order amount in USD",
"columnType": "Number"
}
]
}
],
"feedback": "This datamart covers e-commerce sales data. All amounts are in USD."
}'
{
"id": "sales-analytics"
}
Create a semantic layer for a datamart by adding table descriptions, column metadata, and feedback.
curl --request POST \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts/semantic-layer \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tables": [
{
"name": "orders",
"description": "Customer purchase orders",
"synonyms": ["purchases", "transactions"],
"columns": [
{
"name": "order_id",
"description": "Unique order identifier",
"columnType": "Identifier",
"isIdentifier": true
},
{
"name": "status",
"description": "Current order status",
"synonyms": ["order status", "state"],
"columnType": "ENUM"
},
{
"name": "amount",
"description": "Total order amount in USD",
"columnType": "Number"
}
]
}
],
"feedback": "This datamart covers e-commerce sales data. All amounts are in USD."
}'
{
"id": "sales-analytics"
}
curl --request POST \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts/semantic-layer \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tables": [
{
"name": "orders",
"description": "Customer purchase orders",
"synonyms": ["purchases", "transactions"],
"columns": [
{
"name": "order_id",
"description": "Unique order identifier",
"columnType": "Identifier",
"isIdentifier": true
},
{
"name": "status",
"description": "Current order status",
"synonyms": ["order status", "state"],
"columnType": "ENUM"
},
{
"name": "amount",
"description": "Total order amount in USD",
"columnType": "Number"
}
]
}
],
"feedback": "This datamart covers e-commerce sales data. All amounts are in USD."
}'
{
"id": "sales-analytics"
}
409 SEMANTIC_LAYER_ALREADY_EXISTS if the datamart already has semantic data. Use PUT to modify an existing semantic layer.tables or feedback must be provided in the request body.403 error.
To access your service token:
Authorization: Bearer dbn_live_abc123...
application/json for all requests.Content-Type: application/json
Show Finding datamart names
Show Validation rules
name must match an existing table in the datamartname (when provided) must match an existing column in the respective tableString, Long String, String (Custom), ENUM, Mapper, Range, Expression, Identifier, Number, JSON.Show Column type compatibility
Number cannot be assigned to a varchar column.columnType:String, String (Custom), ENUM, Mapper: plain object mapping values to descriptions (e.g. { "pending": "Not shipped", "shipped": "Sent" })Range: { "lowerLimit": number, "upperLimit": number } (both must be numbers)Expression: string templateJSON: string (sample JSON)Identifier, Number, Long String: omit or use null (non-null config is rejected)Show Config validation
400 INVALID_COLUMN_TYPE_CONFIG with a message describing the required shape.false.false.Show Feedback usage
error field in the JSON body when the request succeeds.
datamartName) on success.| Status Code | Description |
|---|---|
200 | OK — Semantic layer created successfully |
400 | Bad Request — Validation failed (see error codes below) |
401 | Unauthorized — Invalid or missing API token |
403 | Forbidden — Data app token used instead of service token |
409 | Conflict — Semantic layer already exists on this datamart |
500 | Internal Server Error — Server error occurred |
| Error Code | HTTP Status | Description |
|---|---|---|
INVALID_REQUEST_BODY | 400 | Missing required fields or validation failure |
INVALID_DATAMART | 400 | Datamart not found |
INVALID_TABLE | 400 | Table name doesn’t exist in the datamart |
INVALID_COLUMN | 400 | Column name doesn’t exist in the table |
INVALID_COLUMN_TYPE | 400 | Column type incompatible with the column’s datatype |
INVALID_COLUMN_TYPE_CONFIG | 400 | Column type config has wrong shape for the column type |
DUPLICATE_SYNONYM | 400 | Duplicate synonyms detected (case-insensitive) |
SEMANTIC_LAYER_ALREADY_EXISTS | 409 | Datamart already has semantic data — use PUT to update |
AUTHENTICATION_ERROR | 403 | Data app token used instead of service token |
INTERNAL_SERVER_ERROR | 500 | Server error |
Verify your datamart exists
Prepare your semantic metadata
{
"datamartName": "sales-analytics",
"tables": [
{
"name": "orders",
"description": "Customer purchase orders",
"synonyms": ["purchases"],
"columns": [
{ "name": "order_id", "description": "Unique identifier", "columnType": "Identifier" },
{ "name": "amount", "description": "Total in USD", "columnType": "Number" }
]
}
],
"feedback": "All monetary values are in USD."
}
Create the semantic layer
curl --request POST \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts/semantic-layer \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{ ... }'