curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"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
},
{
"name": "total_amount",
"label": "Total Amount",
"isHide": true
}
]
},
{
"schemaName": "public",
"name": "customers",
"label": "Customer Records",
"clientColumn": "tenant_id",
"isHide": false,
"columns": [
{
"name": "customer_id",
"alias": "id",
"isHide": false
},
{
"name": "customer_name",
"alias": "name",
"isHide": false
}
]
}
]
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tenancySettings": {
"tenancyLevel": "TABLE",
"clientColumnType": "STRING",
"schemaName": "public",
"tableName": "clients",
"tableClientNameColumn": "client_name",
"tablePrimaryKeyColumn": "id"
}
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tenancySettings": {
"tenancyLevel": "MULTI_DATABASE",
"primaryDatabase": "core_analytics"
}
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tableList": [
{
"schemaName": "public",
"name": "orders",
"clientColumn": "tenant_id",
"isHide": false,
"columns": [
{"name": "order_id", "alias": "id", "isHide": false},
{"name": "customer_id", "isHide": false}
]
}
],
"tenancySettings": {
"tenancyLevel": "TABLE",
"clientColumnType": "NUMBER",
"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"
}
]
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"relationships": [
{
"parentTableName": "orders",
"parentColumnName": "customer_id",
"childTableName": "customers",
"childColumnName": "id",
"relationshipName": "orders_to_customers",
"cardinality": "ManyToOne",
"join": "LEFT JOIN"
}
]
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tableList": [
{
"schemaName": "public",
"name": "orders",
"label": "Customer Orders",
"columns": [
{
"name": "order_id",
"alias": "id",
"label": "Order ID"
},
{
"name": "quantity",
"label": "Quantity"
},
{
"name": "unit_price",
"alias": "total_revenue",
"label": "Total Revenue",
"isCustomColumn": true,
"sql": "quantity * unit_price"
},
{
"name": "order_date",
"alias": "order_year",
"label": "Order Year",
"isCustomColumn": true,
"sql": "EXTRACT(YEAR FROM order_date)"
},
{
"name": "created_at",
"label": "Created At",
"isApplyTimezone": true
}
]
}
]
}'
const response = await fetch('https://api.usedatabrain.com/api/v2/data-app/datamarts', {
method: 'PUT',
headers: {
'Authorization': 'Bearer dbn_live_abc123...',
'Content-Type': 'application/json'
},
body: JSON.stringify({
datamartName: 'sales-analytics',
tableList: [
{
schemaName: 'public',
name: 'orders',
label: 'Customer Orders',
clientColumn: 'tenant_id',
columns: [
{ name: 'order_id', alias: 'id', label: 'Order ID' },
{ name: 'customer_id', label: 'Customer' },
{ name: 'order_date', alias: 'date', label: 'Order Date' }
]
}
]
})
});
const result = await response.json();
if (result.error) {
console.error('Update failed:', result.error.message);
} else {
console.log('Datamart updated:', result.id);
}
import requests
response = requests.put(
'https://api.usedatabrain.com/api/v2/data-app/datamarts',
headers={
'Authorization': 'Bearer dbn_live_abc123...',
'Content-Type': 'application/json'
},
json={
'datamartName': 'sales-analytics',
'tableList': [
{
'schemaName': 'public',
'name': 'orders',
'label': 'Customer Orders',
'clientColumn': 'tenant_id',
'columns': [
{'name': 'order_id', 'alias': 'id', 'label': 'Order ID'},
{'name': 'customer_id', 'label': 'Customer'}
]
}
],
'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'
}
]
}
)
result = response.json()
if result.get('error'):
print(f"Update failed: {result['error']['message']}")
else:
print(f"Datamart updated: {result['id']}")
require 'net/http'
require 'json'
uri = URI('https://api.usedatabrain.com/api/v2/data-app/datamarts')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri)
request['Authorization'] = 'Bearer dbn_live_abc123...'
request['Content-Type'] = 'application/json'
request.body = {
datamartName: 'sales-analytics',
tableList: [
{
schemaName: 'public',
name: 'orders',
label: 'Customer Orders',
columns: [
{ name: 'order_id', alias: 'id', label: 'Order ID' },
{ name: 'customer_id', label: 'Customer' }
]
}
]
}.to_json
response = http.request(request)
result = JSON.parse(response.body)
if result['error']
puts "Update failed: #{result['error']['message']}"
else
puts "Datamart updated: #{result['id']}"
end
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
type UpdateDatamartRequest struct {
DatamartName string `json:"datamartName"`
TableList []TableInfo `json:"tableList,omitempty"`
TenancySettings *TenancySettings `json:"tenancySettings,omitempty"`
}
type TableInfo struct {
SchemaName string `json:"schemaName,omitempty"`
Name string `json:"name"`
Label string `json:"label,omitempty"`
Columns []ColumnInfo `json:"columns"`
}
type ColumnInfo struct {
Name string `json:"name"`
Alias string `json:"alias,omitempty"`
Label string `json:"label,omitempty"`
IsHide bool `json:"isHide,omitempty"`
}
type TenancySettings struct {
TenancyLevel string `json:"tenancyLevel,omitempty"`
ClientColumnType string `json:"clientColumnType,omitempty"`
SchemaName string `json:"schemaName,omitempty"`
TableName string `json:"tableName,omitempty"`
TableClientNameColumn string `json:"tableClientNameColumn,omitempty"`
TablePrimaryKeyColumn string `json:"tablePrimaryKeyColumn,omitempty"`
}
func main() {
reqData := UpdateDatamartRequest{
DatamartName: "sales-analytics",
TableList: []TableInfo{
{
SchemaName: "public",
Name: "orders",
Label: "Customer Orders",
Columns: []ColumnInfo{
{Name: "order_id", Alias: "id", Label: "Order ID"},
{Name: "customer_id", Label: "Customer"},
},
},
},
}
jsonData, _ := json.Marshal(reqData)
req, _ := http.NewRequest("PUT",
"https://api.usedatabrain.com/api/v2/data-app/datamarts",
bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer dbn_live_abc123...")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
fmt.Println("Datamart updated successfully")
}
<?php
$url = 'https://api.usedatabrain.com/api/v2/data-app/datamarts';
$data = [
'datamartName' => 'sales-analytics',
'tableList' => [
[
'schemaName' => 'public',
'name' => 'orders',
'label' => 'Customer Orders',
'columns' => [
[
'name' => 'order_id',
'alias' => 'id',
'label' => 'Order ID'
],
[
'name' => 'customer_id',
'label' => 'Customer'
]
]
]
]
];
$options = [
'http' => [
'header' => [
'Authorization: Bearer dbn_live_abc123...',
'Content-Type: application/json'
],
'method' => 'PUT',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$result = json_decode($response, true);
if (isset($result['error'])) {
echo "Update failed: " . $result['error']['message'];
} else {
echo "Datamart ID: " . $result['id'];
}
?>
{
"id": "sales-analytics"
}
{
"error": {
"code": "INVALID_DATAMART",
"message": "invalid datamart name."
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "Invalid table or column structure"
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "Invalid schema or table name"
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "Invalid column names in table"
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "\"datamartName\" is required"
}
}
{
"error": {
"code": "INVALID_DATA_APP_API_KEY",
"message": "invalid or expired API KEY, data app not found"
}
}
{
"error": {
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal Server Error"
}
}
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"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
},
{
"name": "total_amount",
"label": "Total Amount",
"isHide": true
}
]
},
{
"schemaName": "public",
"name": "customers",
"label": "Customer Records",
"clientColumn": "tenant_id",
"isHide": false,
"columns": [
{
"name": "customer_id",
"alias": "id",
"isHide": false
},
{
"name": "customer_name",
"alias": "name",
"isHide": false
}
]
}
]
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tenancySettings": {
"tenancyLevel": "TABLE",
"clientColumnType": "STRING",
"schemaName": "public",
"tableName": "clients",
"tableClientNameColumn": "client_name",
"tablePrimaryKeyColumn": "id"
}
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tenancySettings": {
"tenancyLevel": "MULTI_DATABASE",
"primaryDatabase": "core_analytics"
}
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tableList": [
{
"schemaName": "public",
"name": "orders",
"clientColumn": "tenant_id",
"isHide": false,
"columns": [
{"name": "order_id", "alias": "id", "isHide": false},
{"name": "customer_id", "isHide": false}
]
}
],
"tenancySettings": {
"tenancyLevel": "TABLE",
"clientColumnType": "NUMBER",
"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"
}
]
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"relationships": [
{
"parentTableName": "orders",
"parentColumnName": "customer_id",
"childTableName": "customers",
"childColumnName": "id",
"relationshipName": "orders_to_customers",
"cardinality": "ManyToOne",
"join": "LEFT JOIN"
}
]
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tableList": [
{
"schemaName": "public",
"name": "orders",
"label": "Customer Orders",
"columns": [
{
"name": "order_id",
"alias": "id",
"label": "Order ID"
},
{
"name": "quantity",
"label": "Quantity"
},
{
"name": "unit_price",
"alias": "total_revenue",
"label": "Total Revenue",
"isCustomColumn": true,
"sql": "quantity * unit_price"
},
{
"name": "order_date",
"alias": "order_year",
"label": "Order Year",
"isCustomColumn": true,
"sql": "EXTRACT(YEAR FROM order_date)"
},
{
"name": "created_at",
"label": "Created At",
"isApplyTimezone": true
}
]
}
]
}'
const response = await fetch('https://api.usedatabrain.com/api/v2/data-app/datamarts', {
method: 'PUT',
headers: {
'Authorization': 'Bearer dbn_live_abc123...',
'Content-Type': 'application/json'
},
body: JSON.stringify({
datamartName: 'sales-analytics',
tableList: [
{
schemaName: 'public',
name: 'orders',
label: 'Customer Orders',
clientColumn: 'tenant_id',
columns: [
{ name: 'order_id', alias: 'id', label: 'Order ID' },
{ name: 'customer_id', label: 'Customer' },
{ name: 'order_date', alias: 'date', label: 'Order Date' }
]
}
]
})
});
const result = await response.json();
if (result.error) {
console.error('Update failed:', result.error.message);
} else {
console.log('Datamart updated:', result.id);
}
import requests
response = requests.put(
'https://api.usedatabrain.com/api/v2/data-app/datamarts',
headers={
'Authorization': 'Bearer dbn_live_abc123...',
'Content-Type': 'application/json'
},
json={
'datamartName': 'sales-analytics',
'tableList': [
{
'schemaName': 'public',
'name': 'orders',
'label': 'Customer Orders',
'clientColumn': 'tenant_id',
'columns': [
{'name': 'order_id', 'alias': 'id', 'label': 'Order ID'},
{'name': 'customer_id', 'label': 'Customer'}
]
}
],
'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'
}
]
}
)
result = response.json()
if result.get('error'):
print(f"Update failed: {result['error']['message']}")
else:
print(f"Datamart updated: {result['id']}")
require 'net/http'
require 'json'
uri = URI('https://api.usedatabrain.com/api/v2/data-app/datamarts')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri)
request['Authorization'] = 'Bearer dbn_live_abc123...'
request['Content-Type'] = 'application/json'
request.body = {
datamartName: 'sales-analytics',
tableList: [
{
schemaName: 'public',
name: 'orders',
label: 'Customer Orders',
columns: [
{ name: 'order_id', alias: 'id', label: 'Order ID' },
{ name: 'customer_id', label: 'Customer' }
]
}
]
}.to_json
response = http.request(request)
result = JSON.parse(response.body)
if result['error']
puts "Update failed: #{result['error']['message']}"
else
puts "Datamart updated: #{result['id']}"
end
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
type UpdateDatamartRequest struct {
DatamartName string `json:"datamartName"`
TableList []TableInfo `json:"tableList,omitempty"`
TenancySettings *TenancySettings `json:"tenancySettings,omitempty"`
}
type TableInfo struct {
SchemaName string `json:"schemaName,omitempty"`
Name string `json:"name"`
Label string `json:"label,omitempty"`
Columns []ColumnInfo `json:"columns"`
}
type ColumnInfo struct {
Name string `json:"name"`
Alias string `json:"alias,omitempty"`
Label string `json:"label,omitempty"`
IsHide bool `json:"isHide,omitempty"`
}
type TenancySettings struct {
TenancyLevel string `json:"tenancyLevel,omitempty"`
ClientColumnType string `json:"clientColumnType,omitempty"`
SchemaName string `json:"schemaName,omitempty"`
TableName string `json:"tableName,omitempty"`
TableClientNameColumn string `json:"tableClientNameColumn,omitempty"`
TablePrimaryKeyColumn string `json:"tablePrimaryKeyColumn,omitempty"`
}
func main() {
reqData := UpdateDatamartRequest{
DatamartName: "sales-analytics",
TableList: []TableInfo{
{
SchemaName: "public",
Name: "orders",
Label: "Customer Orders",
Columns: []ColumnInfo{
{Name: "order_id", Alias: "id", Label: "Order ID"},
{Name: "customer_id", Label: "Customer"},
},
},
},
}
jsonData, _ := json.Marshal(reqData)
req, _ := http.NewRequest("PUT",
"https://api.usedatabrain.com/api/v2/data-app/datamarts",
bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer dbn_live_abc123...")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
fmt.Println("Datamart updated successfully")
}
<?php
$url = 'https://api.usedatabrain.com/api/v2/data-app/datamarts';
$data = [
'datamartName' => 'sales-analytics',
'tableList' => [
[
'schemaName' => 'public',
'name' => 'orders',
'label' => 'Customer Orders',
'columns' => [
[
'name' => 'order_id',
'alias' => 'id',
'label' => 'Order ID'
],
[
'name' => 'customer_id',
'label' => 'Customer'
]
]
]
]
];
$options = [
'http' => [
'header' => [
'Authorization: Bearer dbn_live_abc123...',
'Content-Type: application/json'
],
'method' => 'PUT',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$result = json_decode($response, true);
if (isset($result['error'])) {
echo "Update failed: " . $result['error']['message'];
} else {
echo "Datamart ID: " . $result['id'];
}
?>
{
"id": "sales-analytics"
}
{
"error": {
"code": "INVALID_DATAMART",
"message": "invalid datamart name."
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "Invalid table or column structure"
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "Invalid schema or table name"
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "Invalid column names in table"
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "\"datamartName\" is required"
}
}
{
"error": {
"code": "INVALID_DATA_APP_API_KEY",
"message": "invalid or expired API KEY, data app not found"
}
}
{
"error": {
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal Server Error"
}
}
Datamart APIs
Update Datamart
Update an existing datamart’s table configurations and tenancy settings without recreating from scratch.
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"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
},
{
"name": "total_amount",
"label": "Total Amount",
"isHide": true
}
]
},
{
"schemaName": "public",
"name": "customers",
"label": "Customer Records",
"clientColumn": "tenant_id",
"isHide": false,
"columns": [
{
"name": "customer_id",
"alias": "id",
"isHide": false
},
{
"name": "customer_name",
"alias": "name",
"isHide": false
}
]
}
]
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tenancySettings": {
"tenancyLevel": "TABLE",
"clientColumnType": "STRING",
"schemaName": "public",
"tableName": "clients",
"tableClientNameColumn": "client_name",
"tablePrimaryKeyColumn": "id"
}
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tenancySettings": {
"tenancyLevel": "MULTI_DATABASE",
"primaryDatabase": "core_analytics"
}
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tableList": [
{
"schemaName": "public",
"name": "orders",
"clientColumn": "tenant_id",
"isHide": false,
"columns": [
{"name": "order_id", "alias": "id", "isHide": false},
{"name": "customer_id", "isHide": false}
]
}
],
"tenancySettings": {
"tenancyLevel": "TABLE",
"clientColumnType": "NUMBER",
"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"
}
]
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"relationships": [
{
"parentTableName": "orders",
"parentColumnName": "customer_id",
"childTableName": "customers",
"childColumnName": "id",
"relationshipName": "orders_to_customers",
"cardinality": "ManyToOne",
"join": "LEFT JOIN"
}
]
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tableList": [
{
"schemaName": "public",
"name": "orders",
"label": "Customer Orders",
"columns": [
{
"name": "order_id",
"alias": "id",
"label": "Order ID"
},
{
"name": "quantity",
"label": "Quantity"
},
{
"name": "unit_price",
"alias": "total_revenue",
"label": "Total Revenue",
"isCustomColumn": true,
"sql": "quantity * unit_price"
},
{
"name": "order_date",
"alias": "order_year",
"label": "Order Year",
"isCustomColumn": true,
"sql": "EXTRACT(YEAR FROM order_date)"
},
{
"name": "created_at",
"label": "Created At",
"isApplyTimezone": true
}
]
}
]
}'
const response = await fetch('https://api.usedatabrain.com/api/v2/data-app/datamarts', {
method: 'PUT',
headers: {
'Authorization': 'Bearer dbn_live_abc123...',
'Content-Type': 'application/json'
},
body: JSON.stringify({
datamartName: 'sales-analytics',
tableList: [
{
schemaName: 'public',
name: 'orders',
label: 'Customer Orders',
clientColumn: 'tenant_id',
columns: [
{ name: 'order_id', alias: 'id', label: 'Order ID' },
{ name: 'customer_id', label: 'Customer' },
{ name: 'order_date', alias: 'date', label: 'Order Date' }
]
}
]
})
});
const result = await response.json();
if (result.error) {
console.error('Update failed:', result.error.message);
} else {
console.log('Datamart updated:', result.id);
}
import requests
response = requests.put(
'https://api.usedatabrain.com/api/v2/data-app/datamarts',
headers={
'Authorization': 'Bearer dbn_live_abc123...',
'Content-Type': 'application/json'
},
json={
'datamartName': 'sales-analytics',
'tableList': [
{
'schemaName': 'public',
'name': 'orders',
'label': 'Customer Orders',
'clientColumn': 'tenant_id',
'columns': [
{'name': 'order_id', 'alias': 'id', 'label': 'Order ID'},
{'name': 'customer_id', 'label': 'Customer'}
]
}
],
'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'
}
]
}
)
result = response.json()
if result.get('error'):
print(f"Update failed: {result['error']['message']}")
else:
print(f"Datamart updated: {result['id']}")
require 'net/http'
require 'json'
uri = URI('https://api.usedatabrain.com/api/v2/data-app/datamarts')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri)
request['Authorization'] = 'Bearer dbn_live_abc123...'
request['Content-Type'] = 'application/json'
request.body = {
datamartName: 'sales-analytics',
tableList: [
{
schemaName: 'public',
name: 'orders',
label: 'Customer Orders',
columns: [
{ name: 'order_id', alias: 'id', label: 'Order ID' },
{ name: 'customer_id', label: 'Customer' }
]
}
]
}.to_json
response = http.request(request)
result = JSON.parse(response.body)
if result['error']
puts "Update failed: #{result['error']['message']}"
else
puts "Datamart updated: #{result['id']}"
end
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
type UpdateDatamartRequest struct {
DatamartName string `json:"datamartName"`
TableList []TableInfo `json:"tableList,omitempty"`
TenancySettings *TenancySettings `json:"tenancySettings,omitempty"`
}
type TableInfo struct {
SchemaName string `json:"schemaName,omitempty"`
Name string `json:"name"`
Label string `json:"label,omitempty"`
Columns []ColumnInfo `json:"columns"`
}
type ColumnInfo struct {
Name string `json:"name"`
Alias string `json:"alias,omitempty"`
Label string `json:"label,omitempty"`
IsHide bool `json:"isHide,omitempty"`
}
type TenancySettings struct {
TenancyLevel string `json:"tenancyLevel,omitempty"`
ClientColumnType string `json:"clientColumnType,omitempty"`
SchemaName string `json:"schemaName,omitempty"`
TableName string `json:"tableName,omitempty"`
TableClientNameColumn string `json:"tableClientNameColumn,omitempty"`
TablePrimaryKeyColumn string `json:"tablePrimaryKeyColumn,omitempty"`
}
func main() {
reqData := UpdateDatamartRequest{
DatamartName: "sales-analytics",
TableList: []TableInfo{
{
SchemaName: "public",
Name: "orders",
Label: "Customer Orders",
Columns: []ColumnInfo{
{Name: "order_id", Alias: "id", Label: "Order ID"},
{Name: "customer_id", Label: "Customer"},
},
},
},
}
jsonData, _ := json.Marshal(reqData)
req, _ := http.NewRequest("PUT",
"https://api.usedatabrain.com/api/v2/data-app/datamarts",
bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer dbn_live_abc123...")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
fmt.Println("Datamart updated successfully")
}
<?php
$url = 'https://api.usedatabrain.com/api/v2/data-app/datamarts';
$data = [
'datamartName' => 'sales-analytics',
'tableList' => [
[
'schemaName' => 'public',
'name' => 'orders',
'label' => 'Customer Orders',
'columns' => [
[
'name' => 'order_id',
'alias' => 'id',
'label' => 'Order ID'
],
[
'name' => 'customer_id',
'label' => 'Customer'
]
]
]
]
];
$options = [
'http' => [
'header' => [
'Authorization: Bearer dbn_live_abc123...',
'Content-Type: application/json'
],
'method' => 'PUT',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$result = json_decode($response, true);
if (isset($result['error'])) {
echo "Update failed: " . $result['error']['message'];
} else {
echo "Datamart ID: " . $result['id'];
}
?>
{
"id": "sales-analytics"
}
{
"error": {
"code": "INVALID_DATAMART",
"message": "invalid datamart name."
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "Invalid table or column structure"
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "Invalid schema or table name"
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "Invalid column names in table"
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "\"datamartName\" is required"
}
}
{
"error": {
"code": "INVALID_DATA_APP_API_KEY",
"message": "invalid or expired API KEY, data app not found"
}
}
{
"error": {
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal Server Error"
}
}
PUT
/
api
/
v2
/
data-app
/
datamarts
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"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
},
{
"name": "total_amount",
"label": "Total Amount",
"isHide": true
}
]
},
{
"schemaName": "public",
"name": "customers",
"label": "Customer Records",
"clientColumn": "tenant_id",
"isHide": false,
"columns": [
{
"name": "customer_id",
"alias": "id",
"isHide": false
},
{
"name": "customer_name",
"alias": "name",
"isHide": false
}
]
}
]
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tenancySettings": {
"tenancyLevel": "TABLE",
"clientColumnType": "STRING",
"schemaName": "public",
"tableName": "clients",
"tableClientNameColumn": "client_name",
"tablePrimaryKeyColumn": "id"
}
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tenancySettings": {
"tenancyLevel": "MULTI_DATABASE",
"primaryDatabase": "core_analytics"
}
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tableList": [
{
"schemaName": "public",
"name": "orders",
"clientColumn": "tenant_id",
"isHide": false,
"columns": [
{"name": "order_id", "alias": "id", "isHide": false},
{"name": "customer_id", "isHide": false}
]
}
],
"tenancySettings": {
"tenancyLevel": "TABLE",
"clientColumnType": "NUMBER",
"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"
}
]
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"relationships": [
{
"parentTableName": "orders",
"parentColumnName": "customer_id",
"childTableName": "customers",
"childColumnName": "id",
"relationshipName": "orders_to_customers",
"cardinality": "ManyToOne",
"join": "LEFT JOIN"
}
]
}'
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tableList": [
{
"schemaName": "public",
"name": "orders",
"label": "Customer Orders",
"columns": [
{
"name": "order_id",
"alias": "id",
"label": "Order ID"
},
{
"name": "quantity",
"label": "Quantity"
},
{
"name": "unit_price",
"alias": "total_revenue",
"label": "Total Revenue",
"isCustomColumn": true,
"sql": "quantity * unit_price"
},
{
"name": "order_date",
"alias": "order_year",
"label": "Order Year",
"isCustomColumn": true,
"sql": "EXTRACT(YEAR FROM order_date)"
},
{
"name": "created_at",
"label": "Created At",
"isApplyTimezone": true
}
]
}
]
}'
const response = await fetch('https://api.usedatabrain.com/api/v2/data-app/datamarts', {
method: 'PUT',
headers: {
'Authorization': 'Bearer dbn_live_abc123...',
'Content-Type': 'application/json'
},
body: JSON.stringify({
datamartName: 'sales-analytics',
tableList: [
{
schemaName: 'public',
name: 'orders',
label: 'Customer Orders',
clientColumn: 'tenant_id',
columns: [
{ name: 'order_id', alias: 'id', label: 'Order ID' },
{ name: 'customer_id', label: 'Customer' },
{ name: 'order_date', alias: 'date', label: 'Order Date' }
]
}
]
})
});
const result = await response.json();
if (result.error) {
console.error('Update failed:', result.error.message);
} else {
console.log('Datamart updated:', result.id);
}
import requests
response = requests.put(
'https://api.usedatabrain.com/api/v2/data-app/datamarts',
headers={
'Authorization': 'Bearer dbn_live_abc123...',
'Content-Type': 'application/json'
},
json={
'datamartName': 'sales-analytics',
'tableList': [
{
'schemaName': 'public',
'name': 'orders',
'label': 'Customer Orders',
'clientColumn': 'tenant_id',
'columns': [
{'name': 'order_id', 'alias': 'id', 'label': 'Order ID'},
{'name': 'customer_id', 'label': 'Customer'}
]
}
],
'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'
}
]
}
)
result = response.json()
if result.get('error'):
print(f"Update failed: {result['error']['message']}")
else:
print(f"Datamart updated: {result['id']}")
require 'net/http'
require 'json'
uri = URI('https://api.usedatabrain.com/api/v2/data-app/datamarts')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri)
request['Authorization'] = 'Bearer dbn_live_abc123...'
request['Content-Type'] = 'application/json'
request.body = {
datamartName: 'sales-analytics',
tableList: [
{
schemaName: 'public',
name: 'orders',
label: 'Customer Orders',
columns: [
{ name: 'order_id', alias: 'id', label: 'Order ID' },
{ name: 'customer_id', label: 'Customer' }
]
}
]
}.to_json
response = http.request(request)
result = JSON.parse(response.body)
if result['error']
puts "Update failed: #{result['error']['message']}"
else
puts "Datamart updated: #{result['id']}"
end
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
type UpdateDatamartRequest struct {
DatamartName string `json:"datamartName"`
TableList []TableInfo `json:"tableList,omitempty"`
TenancySettings *TenancySettings `json:"tenancySettings,omitempty"`
}
type TableInfo struct {
SchemaName string `json:"schemaName,omitempty"`
Name string `json:"name"`
Label string `json:"label,omitempty"`
Columns []ColumnInfo `json:"columns"`
}
type ColumnInfo struct {
Name string `json:"name"`
Alias string `json:"alias,omitempty"`
Label string `json:"label,omitempty"`
IsHide bool `json:"isHide,omitempty"`
}
type TenancySettings struct {
TenancyLevel string `json:"tenancyLevel,omitempty"`
ClientColumnType string `json:"clientColumnType,omitempty"`
SchemaName string `json:"schemaName,omitempty"`
TableName string `json:"tableName,omitempty"`
TableClientNameColumn string `json:"tableClientNameColumn,omitempty"`
TablePrimaryKeyColumn string `json:"tablePrimaryKeyColumn,omitempty"`
}
func main() {
reqData := UpdateDatamartRequest{
DatamartName: "sales-analytics",
TableList: []TableInfo{
{
SchemaName: "public",
Name: "orders",
Label: "Customer Orders",
Columns: []ColumnInfo{
{Name: "order_id", Alias: "id", Label: "Order ID"},
{Name: "customer_id", Label: "Customer"},
},
},
},
}
jsonData, _ := json.Marshal(reqData)
req, _ := http.NewRequest("PUT",
"https://api.usedatabrain.com/api/v2/data-app/datamarts",
bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer dbn_live_abc123...")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
fmt.Println("Datamart updated successfully")
}
<?php
$url = 'https://api.usedatabrain.com/api/v2/data-app/datamarts';
$data = [
'datamartName' => 'sales-analytics',
'tableList' => [
[
'schemaName' => 'public',
'name' => 'orders',
'label' => 'Customer Orders',
'columns' => [
[
'name' => 'order_id',
'alias' => 'id',
'label' => 'Order ID'
],
[
'name' => 'customer_id',
'label' => 'Customer'
]
]
]
]
];
$options = [
'http' => [
'header' => [
'Authorization: Bearer dbn_live_abc123...',
'Content-Type: application/json'
],
'method' => 'PUT',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$result = json_decode($response, true);
if (isset($result['error'])) {
echo "Update failed: " . $result['error']['message'];
} else {
echo "Datamart ID: " . $result['id'];
}
?>
{
"id": "sales-analytics"
}
{
"error": {
"code": "INVALID_DATAMART",
"message": "invalid datamart name."
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "Invalid table or column structure"
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "Invalid schema or table name"
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "Invalid column names in table"
}
}
{
"error": {
"code": "INVALID_REQUEST_BODY",
"message": "\"datamartName\" is required"
}
}
{
"error": {
"code": "INVALID_DATA_APP_API_KEY",
"message": "invalid or expired API KEY, data app not found"
}
}
{
"error": {
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal Server Error"
}
}
Update the table list and tenancy settings of an existing datamart. This endpoint allows you to modify which tables and columns are accessible through the datamart, as well as update multi-tenant configurations.
Destructive Operation: Updating a datamart will delete all existing table and column configurations before applying the new ones. Ensure your new configuration includes all tables and columns you need.
The datamart name identifies which datamart to update and cannot be changed through this endpoint. To rename a datamart, you’ll need to delete the old one and create a new one with the desired name.
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:- 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.
Authorization: Bearer dbn_live_abc123...
Must be set to
application/json for all requests.Content-Type: application/json
Request Body
Name of the existing datamart to update. Must match exactly (case-sensitive).
Show Finding datamart names
Show Finding datamart names
- Use the List Datamarts API to get all datamart names
- Names are case-sensitive and must match exactly
- This field identifies which datamart to update (cannot be used to rename)
Array of tables with columns to include in the datamart. Optional - if not provided, only tenancy settings will be updated.
Replaces all existing tables: The new table list completely replaces the existing configuration. Include all tables you want to keep.
Table name from your datasource. Must exist in the datasource schema.
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.
Show Client column usage
Show Client column usage
- Used for table-level tenancy when
tenancyLevelisTABLE - The column should contain client/tenant identifiers
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.
Show Label usage
Show Label usage
- Provides a user-friendly display name for the table
- Useful when table names are cryptic or technical
- Does not affect the actual table reference in queries
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.
Show OpenSearch wildcard usage
Show OpenSearch wildcard usage
- Only applicable to OpenSearch datasources
- Accepts a valid OpenSearch index wildcard pattern (e.g.,
logs-*,events-2024-*) - When set, the wildcard value is used instead of the exact
namewhen constructing the FROM clause - Allows a single datamart table to cover multiple time-partitioned or sharded OpenSearch indices
List of column objects for this table. Must be non-empty.
Column name from the table. Must exist in the datasource schema.
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. Defaults to
false.Optional flag to mark this as a custom/calculated column. When
true, the sql field is required to define the column’s SQL expression.Show Custom column usage
Show Custom column usage
- Custom columns allow you to define calculated fields using SQL expressions
- The
namefield should reference an existing column from the datasource schema - Use the
aliasfield to give the calculated column a custom display name - The SQL expression can reference other columns from the same table
- Useful for derived metrics, concatenations, or transformations
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.Show SQL expression examples
Show SQL expression examples
- Simple calculation:
quantity * unit_price - Date extraction:
EXTRACT(YEAR FROM order_date) - String concatenation:
CONCAT(first_name, ' ', last_name) - Case statement:
CASE WHEN status = 'active' THEN 1 ELSE 0 END
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.Show Aggregate column usage
Show Aggregate column usage
- Aggregate columns are used for pre-aggregated metrics
- Affects how the column behaves in metric calculations and drag-drop operations
- Common for SUM, COUNT, AVG type pre-calculated values
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.Show Timezone conversion details
Show Timezone conversion details
- Apply to datetime or timestamp columns that store values in UTC or a fixed timezone
- The timezone is sourced from
params.timezonein the guest token — not a user or workspace setting - Supported datasources: Postgres, CockroachDB, Trino, Athena, BigQuery, MSSQL, OpenSearch, Databricks, Clickhouse, Redshift, Snowflake
- Has no effect on non-datetime column types
Multi-tenant configuration for the datamart. Optional - if not provided, existing tenancy settings remain unchanged.
Show Tenancy configuration details
Show Tenancy configuration details
- TABLE level: Uses a dedicated table to map client identifiers
- DATABASE level: Each client has a separate database
- MULTI_DATABASE level: Supports multi-database tenancy with optional primary database routing
- All fields are optional; omitted fields retain their existing values
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
Data type of the client identifier column. Must be either
NUMBER or STRING.Required when tenancySettings.tenancyLevel is set to TABLE in the request.Optional primary database name used for
DATABASE and MULTI_DATABASE tenancy levels.- If
tenancyLevelisDATABASEorMULTI_DATABASE, this value is stored (ornullwhen omitted). - In update requests, if
tenancySettingsis sent withouttenancyLevel, backend logic clearsprimaryDatabasetonull. - If
tenancyLevelisTABLE, backend logic also clearsprimaryDatabasetonull.
To avoid accidental clearing, include
tenancySettings.tenancyLevel whenever you send tenancySettings.Schema name where the client mapping table is located.Required when
tenancySettings.tenancyLevel is set to TABLE in the request.Name of the table that contains client mapping information.Required when
tenancySettings.tenancyLevel is set to TABLE in the request.Column name in the mapping table that stores the client identifier.Required when
tenancySettings.tenancyLevel is set to TABLE in the request.Primary key column of the client mapping table.Required when
tenancySettings.tenancyLevel is set to TABLE in the request.Optional array of table relationships to define how tables in the datamart are connected. Relationships enable joins between tables for more complex queries.
Replaces all existing relationships: When provided, the relationships array completely replaces all existing relationships. Include all relationships you want to keep. If omitted entirely, existing relationships remain unchanged.
Show Relationship configuration
Show Relationship configuration
- Define how tables relate to each other (e.g., orders.customer_id → customers.id)
- Supports different join types and cardinalities
- Useful for creating metrics that span multiple tables
- Optional - omit this field to keep existing relationships unchanged
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 updated datamart (same as the input datamartName) on success.
Examples
HTTP Status Code Summary
| Status Code | Description |
|---|---|
200 | OK - Datamart updated successfully |
400 | Bad Request - Invalid request parameters |
401 | Unauthorized - Invalid or missing API key |
500 | Internal Server Error - Server error occurred |
Possible Errors
| Error Code | HTTP Status | Description |
|---|---|---|
INVALID_REQUEST_BODY | 400 | Missing or invalid parameters |
INVALID_DATAMART | 400 | Datamart not found |
INVALID_DATA_APP_API_KEY | 401 | Invalid API key |
INTERNAL_SERVER_ERROR | 500 | Server error |
Quick Start Guide
Get current configuration
Retrieve the existing datamart configuration before making changes:
curl --request GET \
--url 'https://api.usedatabrain.com/api/v2/data-app/datamarts?isPagination=false' \
--header 'Authorization: Bearer dbn_live_abc123...'
Save this response in case you need to rollback your changes.
Prepare your update
Determine what you want to update:
- Tables/Columns: Prepare the complete new tableList (replaces existing)
- Tenancy: Prepare updated tenancySettings (optional)
- Both: You can update both in a single request
If only updating tenancy, omit the tableList field to keep existing tables intact.
Update the datamart
Make the update request:
curl --request PUT \
--url https://api.usedatabrain.com/api/v2/data-app/datamarts \
--header 'Authorization: Bearer dbn_live_abc123...' \
--header 'Content-Type: application/json' \
--data '{
"datamartName": "sales-analytics",
"tableList": [
{
"schemaName": "public",
"name": "orders",
"label": "Customer Orders",
"clientColumn": "tenant_id",
"columns": [
{"name": "order_id", "alias": "id"},
{"name": "customer_id"}
]
}
]
}'
Successful response returns the datamart name.
Verify the update
Test that the datamart works correctly:
- Load metrics that use this datamart
- Check that all expected tables and columns are accessible
- Verify tenancy is working if you updated those settings
- Monitor for any errors in your dashboards
If metrics break, you can update again with your saved previous configuration to rollback.
Next Steps
Create Datamart
Create a new datamart from scratch
List Datamarts
View all datamarts in your organization
Delete Datamart
Remove datamarts you no longer need
Datamart Concepts
Learn more about datamarts
⌘I

