Skip to main content
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.
This endpoint will reject the request with 409 SEMANTIC_LAYER_ALREADY_EXISTS if the datamart already has semantic data. Use PUT to modify an existing semantic layer.
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 a 403 error. To access your service token:
  1. Go to your Databrain dashboard and open Settings.
  2. Navigate to Settings.
  3. Find the Service Tokens section.
  4. Click the “Generate Token” button to generate a new service token if you don’t have one already.
Use this token as the Bearer value in your Authorization header.

Headers

string
required
Bearer token for API authentication. Use your service token.
string
required
Must be set to application/json for all requests.

Request Body

string
required
Name of the existing datamart to create a semantic layer for. Must match exactly (case-sensitive).
array
Array of table objects with semantic metadata. Each table must reference a table that exists in the datamart.
string
required
Table name from the datamart. Must match an existing table.
string
Optional schema name for the table.
string
Human-readable description of the table. Maximum 500 characters.
string[]
Alternative names for the table. Maximum 10 synonyms, each up to 100 characters. Must be unique (case-insensitive).
string
Additional context for AI query generation. Maximum 1000 characters.
array
Array of column objects with semantic metadata.
string
required
Column name from the table. Must match an existing column.
string
Human-readable description of the column. Maximum 500 characters.
string[]
Alternative names for the column. Maximum 10 synonyms, each up to 100 characters. Must be unique (case-insensitive).
string
Additional context for AI query generation. Maximum 1000 characters.
string
Semantic column type classification. Must be one of: String, Long String, String (Custom), ENUM, Mapper, Range, Expression, Identifier, Number, JSON.
object | string | null
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 template
  • JSON: string (sample JSON)
  • Identifier, Number, Long String: omit or use null (non-null config is rejected)
boolean
Mark this column as an identifier (e.g., primary key, foreign key). Defaults to false.
boolean
Exclude this column from AI indexing. Defaults to false.
string
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 no error field in the JSON body when the request succeeds.
string
The name of the datamart (same as the input datamartName) on success.

Examples

HTTP Status Code Summary

Possible Errors

Quick Start Guide

1

Verify your datamart exists

Use the List Datamarts API to confirm the datamart exists and note its exact name.
2

Prepare your semantic metadata

Gather descriptions, synonyms, and column type classifications for your tables:
3

Create the semantic layer

4

Verify with GET

Retrieve the semantic layer to confirm it was created and check the completion score:

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