Datamart APIs
Create Datamart
Create a new datamart to organize and manage your data sources with custom table and column configurations.
POST
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.
Use this endpoint for all new integrations. This is the recommended 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
- New Endpoint (Recommended)
- Legacy Endpoint (Deprecated Soon)
Authentication
This endpoint requires a service token in the Authorization header. Service tokens differ from data app API keys and provide organization-level permissions.- In Settings page, navigate to the Service Tokens section.
- Click the “Generate Token” button to create 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 datamart to create. Must be unique within your organization — the API will reject the request with an error if a datamart with the same name already exists.
The datasource to which this datamart belongs. Must match an existing datasource in your organization.
Array of tables with columns to include in the datamart. Must be non-empty.
Table name from your datasource.
Optional schema name (required only for schema-based datasources like PostgreSQL, SQL Server).
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.
Optional flag to hide the table from the datamart interface.
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.
Optional wildcard index pattern for OpenSearch tables. When set, this value is used as the table name in queries, enabling you to query multiple OpenSearch indices that match a pattern.
List of column objects for this table. Must be non-empty.
Column name from the table.
Optional alias for the column to display a different name.
Optional label for the column for better readability.
Optional flag to hide the column from the datamart interface.
Optional flag to mark this as a custom/calculated column. When
true, the sql field is required to define the column’s SQL expression.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.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.Optional flag to enable timezone conversion for this column. When
true, the column’s datetime values are converted using the timezone passed as params.timezone in the guest token at query execution time.This field has no effect unless
params.timezone is set in the guest token. See Timezone Handling in Guest Token for the full setup guide.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.
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 instanceMULTI_DATABASE: Tenancy spans multiple databases with optional default routing viaprimaryDatabase
tenancySettings is provided. If tenancySettings is omitted, this field is not needed.Data type of the client identifier column. Must be either
NUMBER or STRING.Required when tenancyLevel is TABLE.Optional primary database name used for
DATABASE and MULTI_DATABASE tenancy levels. Set to null when you do not want a default database.Note: The API accepts this field for all tenancy levels. It is primarily used by DATABASE and MULTI_DATABASE.Schema name where the client mapping table is located.Required when
tenancyLevel is TABLE.Name of the table that contains client mapping information.Required when
tenancyLevel is TABLE.Column name in the mapping table that stores the client identifier.Required when
tenancyLevel is TABLE.Primary key column of the client mapping table.Required when
tenancyLevel is TABLE.Optional array of table relationships to define how tables in the datamart are connected. Relationships enable joins between tables for more complex queries.
Name of the parent table in the relationship.
Column name in the parent table that participates in the relationship.
Name of the child table in the relationship.
Column name in the child table that participates in the relationship.
A descriptive name for the relationship (e.g., “orders_to_customers”).
The cardinality of the relationship. Must be one of:
ManyToMany, ManyToOne, OneToMany, OneToOne.Optional: Can be omitted or set to null if not specified.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
The name of the created datamart (same as the input name).
Error object if the request failed, otherwise
null for successful requests.Examples
Errors
| 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 |
Quick Start Guide
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.
Next Steps
List Datamarts
View all datamarts in your organization
Delete Datamart
Remove datamarts you no longer need
Embed a Pre-built Dashboard/Metric
Use your datamart in embed configurations
Getting Started
Learn how to get started with DataBrain embedding

