Skip to main content
Automatic client scope filters data for the customer identified by your application’s guest token. Configure the customer identifier on each relevant datamart table, then enable automatic scope when your backend creates the token. For example, Acme and Northstar can use the same embedded sales dashboard. With orders.customer_id mapped as the client column, Acme’s session queries Acme’s orders and Northstar’s session queries Northstar’s orders.

What changed

Custom SQL filtering now preserves more existing query structures, including casts, aliases, and grouped conditions. Saved custom SQL metrics are read-only for embedded end users; workspace authors maintain their SQL.

Before you start

You need:
  • A datamart configured for Table tenancy, linked to the workspace and embedding configuration you use.
  • A customer reference table with a primary key and customer-name column.
  • A client-column mapping on every table that contains customer-specific data.
  • A Data App and an embedded dashboard or metric.
  • Access to your application’s backend code that creates guest tokens.
Automatic client scope is optional and must be enabled in the guest token. params.accessPermissions.isAllowAutoClientScope accepts JSON booleans: true enables it; false or omission leaves it disabled. The effective default is false. Database- and schema-based tenancy continue to use their existing tenancy configuration.

Set it up

1

Configure customer identifiers in your datamart

Open your datamart’s tenancy settings. For Table tenancy, select the customer reference table and configure Primary Key, Primary Key Type, and Customer Name.Under Client Column Mapping, select the column that identifies the customer in each customer-specific table. Save your changes with Update when editing an existing configuration.The value your application sends as clientId must match these identifiers. See Configure tenants for the customer reference setup.
A table without a client-column mapping remains unfiltered by automatic client scope. Leave a mapping blank only for intentionally shared data, such as a public country lookup table. If no tables are mapped, automatic scope adds no customer filters.
2

Check the embedding configuration

Confirm that your workspace and embedding configuration use the intended datamart. Client-column mappings displayed in sharing and access settings are read-only; change them in the datamart configuration.
3

Enable automatic scope when creating the guest token

From your application’s backend, add isAllowAutoClientScope: true inside params.accessPermissions. Set clientId from the signed-in user’s authorized customer account.Example request body for the Create guest token API:
Replace the example names and identifier with your own values. Keep any other token parameters your integration needs. The flag belongs under params.accessPermissions, rather than the top-level permissions object.Use the returned guest token in your existing embed integration. Generate a new token with this setting to enable automatic scope for a session. Keep your Data App API key on your backend.
4

Verify with two customer accounts

Load the same dashboard with a token for Acme, then with a separate token for Northstar. Check that each session returns the expected customer’s data.Also check the features you offer: table-backed filter dropdowns, CSV downloads, underlying data, dashboard download archives, and scheduled report attachments. Compare them with the dashboard’s customer context.

Use it day to day

Customers use the embedded dashboard as usual. They can adjust permitted filters and download data when those actions are enabled. Automatic scope applies in the background; customers do not select their own tenant in the embed. To schedule delivery, open Scheduled Reports in the embedded dashboard when enabled. Enter the Subject Line and Send to addresses, choose Charts to Attach, then set the frequency, delivery time, and timezone. Enable Share Download file and select a Download File Format if you want downloadable report files. Save the schedule. Embedded schedules retain the guest-token and embed context used to create them. Their downloadable data uses the token’s customer scope. For an existing schedule, check its saved token and embed context before relying on automatic scope; changing your token-generation code alone does not update the token already associated with that schedule. See Scheduled reports for end users for enabling scheduled reports and email settings for delivery setup.

Existing SQL and other access rules

  • Existing customer placeholders: Saved metric queries and metric CSV downloads that already use a client equality condition such as WHERE customer_id = 'client_id_variable' keep that substitution path. Automatic scope does not add another set of customer filters to those queries. Keep the existing customer conditions complete and correct. Underlying-data execution applies automatic client scope independently when enabled.
  • Custom SQL without a placeholder: With automatic scope enabled, Databrain uses the datamart mappings to filter supported queries. Some custom SQL result-based filter configurations still require an explicit customer placeholder; validate these filters with your query. See the SQL compatibility requirements below.
  • End-user SQL editing: Embedded end users cannot edit saved custom SQL metrics. Ask a workspace author to change the SQL. Permitted filter interactions remain separate from SQL editing.
  • Additional restrictions: Existing row-level security, application filters, and action permissions still apply. Automatic scope does not grant permission to download, view underlying data, or send reports.

API behavior and SQL compatibility

The flag is accepted by POST /api/v2/guest-token/create under params.accessPermissions. It is not a top-level token field or a field under permissions, and the legacy guest-token v1 schema does not accept it. Create a new guest token to change the setting for a session. For guest-token requests to /api/v3/metric/query and /api/v3/metric/download-csv, the backend reads this setting from the token and applies automatic client filters to the final SQL, after query generation. This covers supported pivot, timeseries, group-by, drill, comparison, row-count, year-over-year, and metric-expression queries. Do not add isAllowAutoClientScope to those endpoints’ request bodies. The API-key-authenticated /api/v2/data-app/query endpoint does not gain this guest-token setting. Use table names qualified for your datasource, matching the datamart, with either an explicit AS alias or no alias. For example:
Map the client column on both customer-specific tables. Bare aliases such as public.orders o and unqualified names such as orders are not supported by this automatic filter-injection path and can produce scope errors or invalid SQL. Dashboard filters preserve LEFT, RIGHT, and FULL JOIN types when filtering a joined table; unmatched rows can therefore remain in the result. When automatic scope requires a filter, the backend returns Unable to apply embedded data filters to this query. if it cannot resolve the trusted workspace, embed, or datamart, if a numeric client column receives a non-numeric client ID, or if filter injection leaves the SQL unchanged. Even for numeric client columns, the guest-token request’s clientId must be a JSON string, such as "103".
Automatic scope does not filter unmapped tables or Python-mode metrics. A datamart with no mapped client columns adds no automatic filters. Scope checks detect SQL left unchanged; they do not prove that every mapped table in a complex query received a filter. Test every customer-specific table and join with two customer tokens before relying on the results for tenant isolation.

Troubleshooting