Skip to main content
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
}
POST
https://api.usedatabrain.com
/
api
/
v2
/
data-app
/
datamarts
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 datamarts to organize your data sources into logical business units. Datamarts provide structured access to your datasource tables and columns with optional schema support.
Endpoint Migration Notice: We’re transitioning to kebab-case endpoints. The new endpoint is /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.
Datamarts help organize data sources by defining which tables and columns are accessible. Tenancy settings are optional and can be omitted if multi-tenant data isolation is handled at the application level. Ensure your datasource exists before creating a datamart.

Endpoint Formats

Authentication

This endpoint requires a service token in the Authorization header. Service tokens differ from data app API keys and provide organization-level permissions. 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

Authorization
string
required
Bearer token for API authentication. Use your API key from the data app.
Authorization: Bearer dbn_live_abc123...
Content-Type
string
required
Must be set to application/json for all requests.
Content-Type: application/json

Request Body

name
string
required
Name of the datamart to create. Must be unique within your organization.
datasourceName
string
required
The datasource to which this datamart belongs. Must match an existing datasource in your organization.
tableList
array
required
Array of tables with columns to include in the datamart. Must be non-empty.
tableList.name
string
required
Table name from your datasource.
tableList.schemaName
string
Optional schema name (required only for schema-based datasources like PostgreSQL, SQL Server).
tableList.clientColumn
string
Optional column name in this table that identifies the client/tenant. This column is used for multi-tenant data isolation at the table level. Must exist in the table schema.
tableList.isHide
boolean
Optional flag to hide the table from the datamart interface.
tableList.label
string
Optional label for the table to provide a human-readable display name. When provided, this label can be used in the UI instead of the technical table name for better readability.
tableList.columns
array
required
List of column objects for this table. Must be non-empty.
tableList.columns.name
string
required
Column name from the table.
tableList.columns.alias
string
Optional alias for the column to display a different name.
tableList.columns.label
string
Optional label for the column for better readability.
tableList.columns.isHide
boolean
Optional flag to hide the column from the datamart interface.
tableList.columns.isCustomColumn
boolean
Optional flag to mark this as a custom/calculated column. When true, the sql field is required to define the column’s SQL expression.
tableList.columns.sql
string
SQL expression that defines the calculated value for a custom column. Required when isCustomColumn is true. The expression can reference other columns from the same table.
tableList.columns.isAggregate
boolean
Optional flag to indicate if this column should be treated as an aggregate column. When true, the column is marked as AGGREGATE drop type for metric calculations.
tenancySettings
object
Multi-tenant configuration for the datamart. Defines how data is isolated between different tenants/clients. Optional - if not provided, the datamart will be created without explicit tenancy settings.
tenancySettings.tenancyLevel
string
The level at which tenant isolation occurs. Must be one of: TABLE, DATABASE, or MULTI_DATABASE.
  • TABLE: Client mapping is stored in a specific table (most common)
  • DATABASE: Each client has a separate database instance
  • MULTI_DATABASE: Multiple databases are used for tenant isolation
Required when tenancySettings is provided. If tenancySettings is omitted, this field is not needed.
tenancySettings.clientColumnType
string
Data type of the client identifier column. Must be either NUMBER or STRING.Required when tenancyLevel is TABLE.
tenancySettings.schemaName
string
Schema name where the client mapping table is located.Required when tenancyLevel is TABLE.
tenancySettings.tableName
string
Name of the table that contains client mapping information.Required when tenancyLevel is TABLE.
tenancySettings.tableClientNameColumn
string
Column name in the mapping table that stores the client identifier.Required when tenancyLevel is TABLE.
tenancySettings.tablePrimaryKeyColumn
string
Primary key column of the client mapping table.Required when tenancyLevel is TABLE.
relationships
array
Optional array of table relationships to define how tables in the datamart are connected. Relationships enable joins between tables for more complex queries.
relationships.parentTableName
string
required
Name of the parent table in the relationship.
relationships.parentColumnName
string
required
Column name in the parent table that participates in the relationship.
relationships.childTableName
string
required
Name of the child table in the relationship.
relationships.childColumnName
string
required
Column name in the child table that participates in the relationship.
relationships.relationshipName
string
required
A descriptive name for the relationship (e.g., “orders_to_customers”).
relationships.cardinality
string
The cardinality of the relationship. Must be one of: ManyToMany, ManyToOne, OneToMany, OneToOne.Optional: Can be omitted or set to null if not specified.
relationships.join
string
The type of SQL join to use. Must be one of: INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN.Optional: Can be omitted or set to null if not specified.

Response

id
string
The name of the created datamart (same as the input name).
error
null | object
Error object if the request failed, otherwise null for successful requests.

Examples

Errors

HTTP StatusError CodeDescription
200-Success - Datamart created successfully
400INVALID_REQUEST_BODYInvalid request parameters. Common causes: missing required fields, empty table list, invalid table/column structure, invalid schema/table names, invalid column names, or validation errors from Joi schema.
400AUTH_ERRORInvalid or expired service token
400DATASOURCE_NAME_ERRORThe specified datasource doesn’t exist or you don’t have access to it
500INTERNAL_SERVER_ERRORServer error occurred. Contact support if error persists

Quick Start Guide

1

Verify your datasource

Ensure your datasource exists and is properly configured. You’ll need the exact datasource name as it appears in your DataBrain workspace.
2

Prepare your table structure

Identify the tables and columns you want to include in your datamart:
{
  "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"
    }
  ]
}
3

Create your datamart

Make the API call to 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"
      }
    ]
  }'
4

Use your datamart

Reference your new datamart in embed configurations:
const embedConfig = await createEmbedConfiguration({
  dashboardId: 'your-dashboard-id',
  embedType: 'dashboard',
  workspaceName: 'your-workspace',
  accessSettings: {
    datamartName: 'sales-analytics', // Your new datamart
    // ... other settings
  }
});

Next Steps