Semantic Layer APIs
Create Semantic Layer
Create a semantic layer for a datamart by adding table descriptions, column metadata, and feedback.
POST
Add semantic metadata to a datamart that doesn’t have a semantic layer yet. This includes table and column descriptions, synonyms, column type classifications, and global feedback for AI context.
At least one of
tables or feedback must be provided in the request body.Authentication
This endpoint requires a service token in the Authorization header. Data app API tokens are not permitted and will be rejected with a403 error.
To access your service token:
- Go to your Databrain dashboard and open Settings.
- Navigate to Settings.
- Find the Service Tokens section.
- Click the “Generate Token” button to generate a new service token if you don’t have one already.
Headers
Bearer token for API authentication. Use your service token.
Must be set to
application/json for all requests.Request Body
Name of the existing datamart to create a semantic layer for. Must match exactly (case-sensitive).
Array of table objects with semantic metadata. Each table must reference a table that exists in the datamart.
Table name from the datamart. Must match an existing table.
Optional schema name for the table.
Human-readable description of the table. Maximum 500 characters.
Alternative names for the table. Maximum 10 synonyms, each up to 100 characters. Must be unique (case-insensitive).
Additional context for AI query generation. Maximum 1000 characters.
Array of column objects with semantic metadata.
Column name from the table. Must match an existing column.
Human-readable description of the column. Maximum 500 characters.
Alternative names for the column. Maximum 10 synonyms, each up to 100 characters. Must be unique (case-insensitive).
Additional context for AI query generation. Maximum 1000 characters.
Semantic column type classification. Must be one of:
String, Long String, String (Custom), ENUM, Mapper, Range, Expression, Identifier, Number, JSON.Additional configuration for the column type. Must match the shape expected for
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 usenull(non-null config is rejected)
Mark this column as an identifier (e.g., primary key, foreign key). Defaults to
false.Exclude this column from AI indexing. Defaults to
false.Global feedback text providing context to the AI about this datamart. Maximum 2000 characters.
Response
On success, the response body contains only the datamart name. There is noerror field in the JSON body when the request succeeds.
The name of the datamart (same as the input
datamartName) on success.Examples
HTTP Status Code Summary
| 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 |
Possible Errors
| 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 |
Quick Start Guide
Verify your datamart exists
Use the List Datamarts API to confirm the datamart exists and note its exact name.
Prepare your semantic metadata
Gather descriptions, synonyms, and column type classifications for your tables:
Next Steps
Get Semantic Layer
Retrieve and inspect your semantic layer
Update Semantic Layer
Modify your semantic layer after creation
Delete Semantic Layer
Remove semantic layer metadata
Semantic Layer Guide
Configure the semantic layer in the Databrain UI

