curl --request POST \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "sales-analytics",
"datasourceName": "postgres-main",
"tableList": [
{
"schemaName": "public",
"name": "orders",
"clientColumn": "tenant_id",
"isHide": false,
"columns": [
{
"name": "order_id",
"alias": "id",
"label": "Order ID",
"isHide": false
},
{
"name": "customer_id",
"label": "Customer",
"isHide": false
},
{
"name": "order_date",
"alias": "date",
"label": "Order Date",
"isHide": false
}
]
}
],
"tenancySettings": {
"tenancyLevel": "TABLE",
"clientColumnType": "STRING",
"schemaName": "public",
"tableName": "client_mapping",
"tableClientNameColumn": "client_id",
"tablePrimaryKeyColumn": "id"
}
}'
{
"id": "sales-analytics",
"error": null
}
curl --request POST \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "sales-analytics",
"datasourceName": "postgres-main",
"tableList": [
{
"schemaName": "public",
"name": "orders",
"clientColumn": "tenant_id",
"isHide": false,
"columns": [
{
"name": "order_id",
"alias": "id",
"label": "Order ID",
"isHide": false
},
{
"name": "customer_id",
"label": "Customer",
"isHide": false
},
{
"name": "order_date",
"alias": "date",
"label": "Order Date",
"isHide": false
}
]
}
],
"tenancySettings": {
"tenancyLevel": "TABLE",
"clientColumnType": "STRING",
"schemaName": "public",
"tableName": "client_mapping",
"tableClientNameColumn": "client_id",
"tablePrimaryKeyColumn": "id"
}
}'
{
"id": "sales-analytics",
"error": null
}
Create a new datamart to organize and manage your data sources with custom table and column configurations.
curl --request POST \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "sales-analytics",
"datasourceName": "postgres-main",
"tableList": [
{
"schemaName": "public",
"name": "orders",
"clientColumn": "tenant_id",
"isHide": false,
"columns": [
{
"name": "order_id",
"alias": "id",
"label": "Order ID",
"isHide": false
},
{
"name": "customer_id",
"label": "Customer",
"isHide": false
},
{
"name": "order_date",
"alias": "date",
"label": "Order Date",
"isHide": false
}
]
}
],
"tenancySettings": {
"tenancyLevel": "TABLE",
"clientColumnType": "STRING",
"schemaName": "public",
"tableName": "client_mapping",
"tableClientNameColumn": "client_id",
"tablePrimaryKeyColumn": "id"
}
}'
{
"id": "sales-analytics",
"error": null
}
curl --request POST \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "sales-analytics",
"datasourceName": "postgres-main",
"tableList": [
{
"schemaName": "public",
"name": "orders",
"clientColumn": "tenant_id",
"isHide": false,
"columns": [
{
"name": "order_id",
"alias": "id",
"label": "Order ID",
"isHide": false
},
{
"name": "customer_id",
"label": "Customer",
"isHide": false
},
{
"name": "order_date",
"alias": "date",
"label": "Order Date",
"isHide": false
}
]
}
],
"tenancySettings": {
"tenancyLevel": "TABLE",
"clientColumnType": "STRING",
"schemaName": "public",
"tableName": "client_mapping",
"tableClientNameColumn": "client_id",
"tablePrimaryKeyColumn": "id"
}
}'
{
"id": "sales-analytics",
"error": null
}
/api/v2/data-app/datamarts. The old endpoint /api/v2/dataApp/datamarts will be deprecated soon. Please update your integrations to use the new endpoint format.POST https://api.usedatabrain.com/api/v2/data-app/datamarts
POST https://api.usedatabrain.com/api/v2/data-app/datamarts
Authorization: Bearer dbn_live_abc123...
application/json for all requests.Content-Type: application/json
Show Naming guidelines
Show Finding datasource names
Show Client column usage
tenancyLevel is TABLEShow Label usage
true, the sql field is required to define the column’s SQL expression.Show Custom column usage
name field should reference an existing column from the datasource schemaalias field to give the calculated column a custom display nameisCustomColumn is true. The expression can reference other columns from the same table.Show SQL expression examples
quantity * unit_priceEXTRACT(YEAR FROM order_date)CONCAT(first_name, ' ', last_name)CASE WHEN status = 'active' THEN 1 ELSE 0 ENDtrue, the column is marked as AGGREGATE drop type for metric calculations.Show Aggregate column usage
true, the column’s datetime values will be adjusted to the viewer’s timezone during metric calculations and data retrieval.Show Timezone conversion usage
Show Tenancy configuration details
TABLE or DATABASE.TABLE: Client mapping is stored in a specific table (most common)DATABASE: Each client has a separate database instancetenancySettings is provided. If tenancySettings is omitted, this field is not needed.NUMBER or STRING.Required when tenancyLevel is TABLE.tenancyLevel is TABLE.tenancyLevel is TABLE.tenancyLevel is TABLE.tenancyLevel is TABLE.Show Relationship configuration
ManyToMany, ManyToOne, OneToMany, OneToOne.Optional: Can be omitted or set to null if not specified.INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN.Optional: Can be omitted or set to null if not specified.null for successful requests.| HTTP Status | Error Code | Description |
|---|---|---|
200 | - | Success - Datamart created successfully |
200 | - | Success - Datamart created successfully |
400 | INVALID_REQUEST_BODY | Invalid request parameters. Common causes: missing required fields, empty table list, invalid table/column structure, invalid schema/table names, invalid column names, validation errors from Joi schema, or duplicate datamart name ("Datamart name already exists"). |
400 | AUTH_ERROR | Invalid or expired service token |
400 | DATASOURCE_NAME_ERROR | The specified datasource doesn’t exist or you don’t have access to it |
500 | INTERNAL_SERVER_ERROR | Server error occurred. Contact support if error persists |
Verify your datasource
Prepare your table structure
{
"name": "sales-analytics",
"datasourceName": "postgres-main",
"tableList": [
{
"schemaName": "public",
"name": "orders",
"label": "Customer Orders",
"clientColumn": "tenant_id",
"isHide": false,
"columns": [
{"name": "order_id", "alias": "id", "label": "Order ID", "isHide": false},
{"name": "customer_id", "label": "Customer", "isHide": false},
{"name": "order_date", "alias": "date", "label": "Order Date", "isHide": false}
]
}
],
"tenancySettings": {
"tenancyLevel": "TABLE",
"clientColumnType": "STRING",
"schemaName": "public",
"tableName": "client_mapping",
"tableClientNameColumn": "client_id",
"tablePrimaryKeyColumn": "id"
},
"relationships": [
{
"parentTableName": "orders",
"parentColumnName": "customer_id",
"childTableName": "customers",
"childColumnName": "id",
"relationshipName": "orders_to_customers",
"cardinality": "ManyToOne",
"join": "LEFT JOIN"
}
]
}
Create your datamart
curl --request POST \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"name": "sales-analytics",
"datasourceName": "postgres-main",
"tableList": [
{
"schemaName": "public",
"name": "orders",
"clientColumn": "tenant_id",
"isHide": false,
"columns": [
{"name": "order_id", "alias": "id", "label": "Order ID", "isHide": false},
{"name": "customer_id", "label": "Customer", "isHide": false}
]
}
],
"tenancySettings": {
"tenancyLevel": "TABLE",
"clientColumnType": "STRING",
"schemaName": "public",
"tableName": "client_mapping",
"tableClientNameColumn": "client_id",
"tablePrimaryKeyColumn": "id"
},
"relationships": [
{
"parentTableName": "orders",
"parentColumnName": "customer_id",
"childTableName": "customers",
"childColumnName": "id",
"relationshipName": "orders_to_customers",
"cardinality": "ManyToOne",
"join": "LEFT JOIN"
}
]
}'
Use your datamart
const embedConfig = await createEmbedConfiguration({
dashboardId: 'your-dashboard-id',
embedType: 'dashboard',
workspaceName: 'your-workspace',
accessSettings: {
datamartName: 'sales-analytics', // Your new datamart
// ... other settings
}
});