Authentication
Create a guest token
Mint a short-lived token that lets one of your customers view your embedded dashboards and metrics. Covers the body, clientId, expiry, response and errors.
Your backend calls this endpoint when a customer opens a page with an embed. Pass the returned token to the Databrain web component. Never call it from the browser: the API token must stay on your server.
curl --request POST https://api.usedatabrain.com/api/v2/guest-token/create \ --header "Authorization: Bearer $DATABRAIN_API_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "clientId": "acme", "dataAppName": "Customer analytics", "expiryTime": 3600000, "params": { "userIdentifier": "jane@acme.com" } }'Before you start
- You have a data app API token for the data app. A service token does not work here. See Authentication.
- Your plan includes embedding (Enterprise, a trial, or self-hosted).
DataAppApiTokenAuthorizationBearer <token>A data app API token. A service token is refused.
Body
Only clientId and dataAppName are required. The body is validated strictly: an unknown field returns 400 INVALID_REQUEST_BODY. dataAppId, client_id, tenant_id, workspaceName and permissions.dashboards are not fields.
The tenant whose rows this viewer sees. It is not a person's id: every user of the same customer gets the same clientId. See the table below.
The data app's name exactly as saved, with its spaces and capital letters. Must belong to the data app of your API token.
Lifetime in milliseconds from now. Must be positive. A numeric string such as "3600000" also works. Default: 24 hours. Common values: 900000 (15 minutes), 3600000 (1 hour), 86400000 (24 hours). See Expiry for the cap.
Multi-datasource workspaces: the datasource this viewer queries. Send it when the workspace uses more than one datasource. Use the name from Data Studio > Datasources.
"datasourceName": "orders_pg"Multi-datamart workspaces: the datamart this viewer queries. Ignored when datasourceName is set. When you send neither, Databrain uses the default of the data app's workspace.
"datamartName": "Orders sample"Filters, visibility and viewer settings. Every field is optional. The examples use the sample data on this page.
10 fields in params
The person who views the embed, for example their email or your user id. It does not filter rows: clientId does that.
Databrain saves this value as the owner of the metrics and scheduled reports this person makes in the embed. A metric they keep private is hidden from other viewers of the same clientId. Saved boards belong to the clientId, not to this value.
Only the person who made a metric can publish it or make it private again. With isAllowPrivateMetricsByDefault on the dashboard (see Create a dashboard embed), a new metric stays private to its maker until they publish it.
Default: no owner. Every viewer of the clientId sees every metric made in the embed. The match is exact: Jane@acme.com and jane@acme.com are two people. Use a value that stays the same for the person across sessions.
"userIdentifier": "jane@acme.example"The time zone Databrain uses when it runs this viewer's queries. Use an IANA name, for example Asia/Kolkata or America/New_York. A time stored with a UTC offset moves to this zone, so its day and month can change. See the worked example.
Default: the time zone of the warehouse session. Send UTC if you want UTC every time. Common values: UTC, America/New_York, America/Los_Angeles, Europe/London, Asia/Kolkata, Australia/Sydney.
"timezone": "America/New_York"Case does not matter (asia/kolkata works). Spaces at the start and end are removed. An unknown name returns 400 INVALID_REQUEST_BODY "Invalid timezone", and "" is refused. Releases with offset support also accept a UTC offset such as +05:30. See how offsets map to zone names. Use an IANA name across releases.
Supported datasources. Databrain sets this time zone on the query session for:
- PostgreSQL
- CockroachDB
- Snowflake
- MySQL
- Athena
- Databricks
- ClickHouse
- Amazon S3
- CSV
On BigQuery, Microsoft SQL Server, Microsoft Fabric, Trino and Redshift, the session time zone is not set. Turn on Apply timezone on the datamart date column, and date filters use this time zone. On SingleStore, Firebolt, MongoDB, OpenSearch and Elasticsearch, timezone has no effect. See Set the viewer's timezone.
The embeds this token can open. Use the Key of each embed, from the data app's Embeds tab. It is the same value as the dashboard-id on your page. Where dashboard IDs are supported, Databrain looks for an embed ID first and then a dashboard ID.
Default: every embed of the data app.
"allowedEmbeds": ["orders-overview"]The match is exact and case-sensitive. An entry that matches neither allows nothing. If the response includes warnings, check it for unmatched entries. Loading an embed outside the list fails with UNAUTHORIZED, and the viewer sees "This dashboard could not be loaded". The second embed of the same dashboard has its own key, for example orders-overview__nmSy5CFC.
Fixed values for metric filters that have App Filter turned on. The viewer does not see the filter and cannot change it. One entry per metric: metricId is the Metric ID of the metric, and each key in values is the filter's name.
Default: no value. A metric with an app filter and no value shows "Not set up for your account" (METRIC_OUT_OF_SCOPE).
"appFilters": [ { "metricId": "amount-by-region", "values": { "category": "Hardware" } }]The value follows the filter type:
| Filter | Value |
|---|---|
| Single-select | "category": "Hardware" |
| Multi-select | "category": ["Hardware", "Software"] |
| Boolean | "paid_orders": true |
| Date preset | "ordered_at": "Last 30 days", a preset the filter has |
| Values from SQL | "region": { "sql": "SELECT region FROM main.regions WHERE active", "columnName": "region" } |
The name must match the saved name exactly, capital letters too: Category returns 400 APP_FILTER_PARAM_ERROR "Invalid app filter name: Category". A filter without App Filter, an unknown metric, a preset the filter does not have, or SQL that is not one SELECT returns the same error. See Metric app filter.
Fixed values for dashboard filters that have App Filter turned on. The filter applies to every metric on that dashboard, except the metrics in its Restrict Metrics list. The viewer does not see the filter.
dashboardId is the Dashboard ID you gave the dashboard. It is also the Key of the dashboard's first embed. Each key in values is the filter name or label. Capital letters do not count here: REGION matches region.
Default: no value. A dashboard app filter with no value makes its metrics show "Not set up for your account".
"dashboardAppFilters": [ { "dashboardId": "orders-overview", "values": { "region": "EU" }, "isShowOnUrl": false }]The value follows the filter type:
| Filter | Value |
|---|---|
| Single-select | "region": "EU" |
| Multi-select | "region": ["EU", "NA"] |
| Date range | "ordered_at": { "startDate": "2026-01-01", "endDate": "2026-01-31" } |
| Date preset | "ordered_at": "Last 30 days" |
| Number range | "amount": { "min": 100, "max": 500 } |
| Values from SQL | "region": { "sql": "SELECT region FROM main.regions WHERE active", "columnName": "region" } |
isShowOnUrl matters only when the embed writes filters to the page URL (options with "isModifyUrl": true). Leave it out or send false to keep the value out of the URL. With true, the URL gets dbn.orders-overview.region=EU.
An unknown dashboardId, a second embed's key such as orders-overview__nmSy5CFC, or a name that is not an app filter returns 400 APP_FILTER_PARAM_ERROR. See Dashboard app filter.
3 fields in dashboardAppFilters
Values for row-level security filters on a metric: { "metricId": "...", "values": { "<filter name>": <value> } }. Each key must be the exact name of a row-level security filter saved in one of the data app's workspaces. The value replaces <filter name>_variable in the metric's SQL. Databrain applies it on the server: the viewer cannot see or change it.
Default: no value.
"rlsSettings": [ { "metricId": "amount-by-region", "values": { "region_rls": "EU" } }]A name that is not saved returns 400 RLS_SETTINGS_PARAM_ERROR "Invalid rls filter name: region_rls". Databrain does not check metricId when it makes the token. New setups use tableAppFilters or app filters instead.
A filter on one table column for every query this token runs. You do not need a filter on the metric or the dashboard. It only removes rows: it never shows rows of another clientId.
Default: no table filter.
"tableAppFilters": [ { "tableName": "main.guest_token_orders", "columnName": "tenant_id", "values": ["acme"] }]tableNameisschema.tableas the datamart shows it. A name without a schema returns400 INVALID_REQUEST_BODY.- The table and the column must be in the datamart, else
400 INVALID_TABLE_APP_FILTER. The workspace must use a datamart. Capital letters do not count. - Up to 50 entries and 1 to 1,000 values each. Two entries for the same column return
400 INVALID_REQUEST_BODY: put all values in one entry. - A chart whose SQL Databrain cannot filter shows
TABLE_APP_FILTER_NOT_APPLIED(E1007). It never runs without the filter.
503 fields in tableAppFilters
256Pattern: ^[^\s"'`\[\];.\\]+(\.[^\s"'`\[\];.\\]+)+$128Pattern: ^[^"'`\[\];.\\]+$1Max items: 1000Metrics to hide on a dashboard for this viewer: { "dashboardId": "...", "metricIds": ["..."] }. dashboardId is the same id as in dashboardAppFilters.
Default: every metric shows.
"hideDashboardMetrics": [ { "dashboardId": "orders-overview", "metricIds": ["amount-by-month"] }]The cards are removed from that dashboard for this token only. Nothing is deleted or archived, and other dashboards do not change. Two entries for the same dashboard add up. An unknown dashboard returns 400 DASHBOARD_PARAM_ERROR. A metric that is not on that dashboard returns 400 INVALID_METRIC_ID.
2 fields in hideDashboardMetrics
Dashboard filters to hide, by their label. It only hides the control. To also fix the value, use dashboardAppFilters.
Default: every filter shows.
"hideDashboardFilters": ["category"]The label must match exactly, capital letters too. Category does not hide category. A label with no match hides nothing. If the response includes warnings, check it for unmatched labels.
What the viewer can do with filters, and automatic client scope. A value in the token wins over the embed's Access control setting, false too. When the token leaves a field out, the Access control setting applies. Unknown fields return 400 INVALID_REQUEST_BODY.
7 fields in accessPermissions
The viewer can add dashboard filters. They see a + next to the filters. Access control label: Add dashboard filters. Default: off.
The viewer can add filters to a metric. Access control label: Add metric filters. Default: off.
The viewer can rename dashboard filters. They see a pencil next to the filters. Access control label: Rename dashboard filters. Default: off.
The viewer can rename metric filters. Access control label: Rename metric filters. Default: off.
The columns the viewer can use in new dashboard filters: [{ "tableName": "main.guest_token_orders", "columns": ["region", "category"] }]. Both keys are required in each entry. It can only narrow the columns the embed allows, never add more. [] allows no columns. Capital letters do not count, and guest_token_orders also matches main.guest_token_orders. Unknown names are not an error: they match nothing. Default: the embed's columns.
The same as dashboardFilterColumns, for new metric filters.
Table tenancy only. Adds client column = clientId to every datamart table that has a client column. It covers charts, filter options, downloads, underlying data and scheduled report files of this token. Use it when a metric has no client filter of its own. Send it in the token: a query body cannot turn it on. Tables with no client column in the datamart are not filtered. A query it cannot scope is refused with "Unable to apply embedded data filters to this query" (E1004). Default: off. See Automatic client scope.
The embed must have a table list. An embed made with Create embed has one. An embed made in the app has one only when Create metrics, Add dashboard filters or Add metric filters is on in its Access control. Without it, every chart shows E1004.
What the viewer can do in the embed. A value in the token wins over the embed's Access control setting, false too. When the token leaves a field out, the Access control setting applies. Unknown fields return 400 INVALID_REQUEST_BODY.
"permissions": { "isEnableUnderlyingData": true, "isShowDashboardName": false }10 fields in permissions
The viewer can delete (archive) metrics. Access control label: Delete metrics. Default: off. With false, Databrain also refuses the archive call (403). A viewer can always archive a metric they made.
The viewer sees Manage Metrics in the dashboard Settings menu. Access control label: Manage metrics. Default: off.
The viewer can save boards (saved filter views). Access control label: Create boards. The dashboard also needs Enable board in its settings. Saving a board follows the Access control setting, not this field. Default: off.
The viewer sees Edit in a metric's menu. Access control label: Edit metrics. Default: off.
The viewer sees Customize Layout in the dashboard Settings menu, and can move and resize cards. Access control label: Customize dashboard layout. Default: off.
The viewer sees View underlying data in a metric's menu. Access control label: View underlying data. Default: off.
The viewer can download metric data. There is no Access control setting for it. Default: on. Send false to hide the download option in the embed.
Shows the dashboard's side panel. There is no Access control setting for it. Default: on.
Shows the dashboard name at the top. There is no Access control setting for it. Default: on. The web component option hideDashboardName wins over it.
true turns metric creation off for this viewer, even when the embed's Create metrics is on. A token cannot turn creation on: use Create metrics in Access control. A create call is refused with 403 METRIC_ACCESS_DENIED. The web component option disableMetricCreation also hides creation, see Options. Default: follows Create metrics.
What to send as clientId
| Tenancy of the datamart | clientId |
|---|---|
| Row per tenant (a tenant column) | The tenant column value for this customer, exactly as stored, for example "104" |
| Schema or database per tenant | The tenant's schema or database name, as mapped in the datamart |
| Datasource per tenant | The tenant name mapped to that customer's datasource |
| No tenancy | Any non-empty string, for example "None". It is not used |
Take the value from your server session, never from the browser. "104" and "0104" are different tenants. A value that matches no tenant never widens access.
Databrain can also check the clientId against the tenancy before it makes the token. When the client ID check is on for your organization, a value that matches no tenant returns 400 CLIENT_ID_ERROR, and a client ID check that cannot run returns 503 CLIENT_ID_ERROR. When the check is off, the token is made, and the embed shows no rows or an error for that tenant. Do not use the response of this endpoint as the only test of a clientId.
Expiry
- A company on the current plans gets a token that lives at most 24 hours. A longer
expiryTimeis not refused: the token gets 24 hours, andexpireAtin the response shows the real expiry. - Legacy contracts and self-hosted installs get the
expiryTimeyou send. Self-hosted can change the default withGUEST_TOKEN_DEFAULT_EXPIRY_MS.
Timezone worked example
The sample CSV has this order for acme. The time ends in Z, so it is UTC.
order_id,tenant_id,region,category,amount,ordered_at1005,acme,EU,Hardware,300.00,2026-01-31T23:30:00Z1006,acme,NA,Software,75.00,2026-02-01T02:00:00ZA metric shows the sum of amount by month of ordered_at. These are the totals for acme with three tokens:
timezone in the token | Order 1005 is on | Order 1006 is on | January | February |
|---|---|---|---|---|
Not sent, or UTC | 31 January, 23:30 | 1 February, 02:00 | 750 | 485 |
Asia/Kolkata (UTC+5:30) | 1 February, 05:00 | 1 February, 07:30 | 450 | 785 |
America/New_York (UTC-5) | 31 January, 18:30 | 31 January, 21:00 | 825 | 410 |
The same rows move to another month because the day changes in the viewer's zone. We got the same totals from this CSV and from a PostgreSQL timestamptz column.
What moves depends on how the warehouse stores the time:
- Stored with a UTC offset (PostgreSQL
timestamptz, or CSV text that ends inZor+00:00): grouping and date filters move to the token's zone. Databrain sets the session time zone before each query on PostgreSQL, CockroachDB, Snowflake, MySQL, Athena, Databricks, ClickHouse, Amazon S3 and CSV. - Stored without an offset (PostgreSQL
timestamp): the value is read as it is, and the month grouping does not move. In date filters, Apply timezone on the datamart column converts it. See Set the viewer's timezone.
Try it with sample data
Use a small CSV to see each field change the embed before you use your own data.
- Download guest-token-orders.csv. It has 24 made-up orders for three tenants:
acme,globexandinitech. - Connect it as a CSV datasource. On its Tenancy tab, select Table, the table
main.guest_token_orders, andtenant_idfor both columns. - Make a datamart with this table and
tenant_idas its client column, for example with Create a datamart. Make a workspace that uses the datamart. - Make a dashboard with the Dashboard ID
orders-overviewand two metrics. Both metrics get a client filter ontenant_id.- Amount by region, Metric ID
amount-by-region: sum ofamountbyregion, with a metric filtercategorythat has App Filter on. - Amount by month, Metric ID
amount-by-month: sum ofamountby month ofordered_at.
- Amount by region, Metric ID
- Add two dashboard filters:
regionwith App Filter on and Amount by month in Restrict Metrics, andcategorywith App Filter off. - Make an embedded data app
Orders portalfor the workspace, embed the dashboard, and make an API token. - Make a token with this body:
{ "clientId": "acme", "dataAppName": "Orders portal", "expiryTime": 3600000, "params": { "userIdentifier": "jane@acme.example", "timezone": "Asia/Kolkata", "allowedEmbeds": ["orders-overview"], "dashboardAppFilters": [ { "dashboardId": "orders-overview", "values": { "region": "EU" } } ], "appFilters": [ { "metricId": "amount-by-region", "values": { "category": "Hardware" } } ], "hideDashboardFilters": ["category"], "accessPermissions": { "isAllowEndUserDashboardFilter": false } }, "permissions": { "isEnableUnderlyingData": true, "isShowDashboardName": false }}The embed shows no dashboard name and no category filter. Amount by region shows one bar, EU, with 420: the acme Hardware orders in EU. Amount by month shows 450 for January and 785 for February. Change one field at a time to see what it does.
Response
{ "token": "5b0c8e3a-2f1d-4c6b-9e7a-8d4f2a1b3c5d", "expireAt": "2026-11-20T10:00:00.000Z", "warnings": [ "hideDashboardFilters: no dashboard filter has the label \"category\", so nothing is hidden. Labels match exactly; did you mean \"Category\"?" ]}| Field | Type | Description |
|---|---|---|
token | string | The guest token. Pass it to the web component |
expireAt | string | When the token expires (ISO 8601). It can be earlier than you asked |
warnings | string[] | Only when a field matches nothing: an allowedEmbeds id with no embed, a hideDashboardFilters label with no filter, or a timezone offset with no fixed zone. The token is made anyway. Fix the value, or the token does less than you meant. A token made through OAuth gets only the timezone warning |
Errors
| Status | error.code | Why |
|---|---|---|
| 400 | INVALID_REQUEST_BODY | A field is missing, unknown, or of the wrong type. expiryTime is not a positive number. timezone is not a valid time zone. A tableAppFilters table name has no schema, or two entries name the same column |
| 400 | INVALID_DATA_APP_NAME | No data app has this name |
| 400 | AUTHENTICATION_ERROR | The API token does not belong to this data app, or it is a service token |
| 400 | CLIENT_ID_ERROR | The clientId check is on for your organization, and the clientId matches no tenant. hint says what the tenancy expects |
| 400 | DATASOURCE_NAME_ERROR | No datasource has this datasourceName |
| 400 | DATAMART_NAME_ERROR | No datamart has this datamartName |
| 400 | APP_FILTER_PARAM_ERROR | An appFilters or dashboardAppFilters entry is not valid: an unknown metric or dashboard id, a name that is not an app filter, an unsafe SQL value, or a preset date option the filter does not have |
| 400 | RLS_SETTINGS_PARAM_ERROR | An rlsSettings key is not a row-level security filter name |
| 400 | INVALID_TABLE_APP_FILTER | A tableAppFilters table or column is not in the datamart, or there is no datamart |
| 400 | DASHBOARD_PARAM_ERROR or INVALID_METRIC_ID | A hideDashboardMetrics entry names a dashboard or metric outside this data app |
| 403 | entitlement_required | Your plan does not include embedding |
| 503 | CLIENT_ID_ERROR | The clientId check is on for your organization, and Databrain could not run it right now. No token was made. Try again |
| 503 | entitlement_check_unavailable | Databrain could not check your plan. Try again |
These are the errors of this endpoint. Errors after the embed loads, for example TOKEN_EXPIRED or UNAUTHORIZED_ORIGIN, are on Error codes. For errors that every endpoint returns, see Authentication.
Older version
POST /api/v1/guest-token/create still works for older integrations. It takes workspaceName instead of dataAppName and refuses a data app API token. It also needs embedding on your plan. Use v2 for new code. See the API migration guide.
curl -X POST 'https://api.usedatabrain.com/api/v2/guest-token/create' \ -H 'Content-Type: application/json' \ -d '{ "clientId": "acme", "dataAppName": "Customer analytics", "expiryTime": 3600000, "params": { "userIdentifier": "jane@acme.com" }}'{ "token": "5b0c8e3a-2f1d-4c6b-9e7a-8d4f2a1b3c5d", "expireAt": "2026-11-20T10:00:00.000Z"}