Skip to Content

Filtering & Personalization

Set dashboard filters from the token

Lock a dashboard filter to a value your backend puts in the guest token, so viewers cannot change it. See the values you can pass and how names match.

Do this with your agent

embed-dashboard

Help me with this Databrain task: Set dashboard filters from the token. Check the current dashboard, host app and guest token scope where relevant. Show the planned changes and how to verify them. Ask before applying changes.

A dashboard app filter takes its value from params.dashboardAppFilters in the guest token. Viewers cannot change it.

Before you start

  • You have a dashboard that a data app shares.
  • Your backend creates guest tokens. See Guest token API.

Steps

Follow the written steps if you prefer text.

  1. Open the dashboard and select Add filter, then Select.

    Dashboard filter bar with the Add filter menu open and the Select option highlighted above Switch Select and Other
    Add filter is in the filter bar under the dashboard name.
  2. In Step 1 of 2: Filter values, enter a Filter Name, for example region. This name is the key in the token.

    Add filter dialog, Step 1 of 2, with Filter Name region highlighted, Option Type Auto and Filter Variant Multi-Select
    The filter name is the key you send in the token.
  3. Pick the Filter Variant, for example Multi-Select. In Values from, choose the Dataset and the column that hold the values, then select Next.

    Values from section with Dataset main.subscription_orders, column region, and the Next button highlighted
    The dataset and column give the filter its list of values.
  4. In Step 2 of 2: Apply filter, keep Target on Apply on and choose the columns.

    Add filter dialog, Step 2 of 2, Target Apply on, Dataset main.subscription_orders and the column region highlighted
    Apply on adds the filter to every metric that reads this column.
  5. Turn on App Filter, then select Save. The filter shows in the filter bar of the dashboard.

    App Filter switch turned on and highlighted, with the note about params.dashboardAppFilters, and the Prev and Save buttons
    App Filter makes the token the only source of the value.
  6. Copy the dashboard ID: the Key of the dashboard embed on the data app’s Embeds tab. See Dashboard ID.

    Embeds tab with the Key cell of the Revenue overview dashboard embed highlighted
    Use the Key of the dashboard embed as dashboardId.
  7. In your backend, add the filter to params.dashboardAppFilters when you create the guest token:

{
  "clientId": "acme-corp",
  "dataAppName": "Customer Analytics",
  "params": {
    "dashboardAppFilters": [
      {
        "dashboardId": "YOUR_DASHBOARD_ID",
        "values": {
          "region": ["Europe", "Asia Pacific"],
          "order date": { "startDate": "2026-01-01", "endDate": "2026-03-31" },
          "price": { "min": 100, "max": 900 }
        },
        "isShowOnUrl": false
      }
    ]
  }
}

The dashboard opens with these filter values for the life of the token.

Embedded Revenue overview dashboard in an example host app, with the Revenue by region chart showing only Europe and Asia Pacific
The token sends region Europe and Asia Pacific, so the chart shows only those two.

Values you can pass

Filter typeValue
Single selectOne string, number or boolean, for example "USA"
Multi selectAn array, for example ["USA", "Canada"]
Date picker{ "startDate": "2026-01-01", "endDate": "2026-03-31" }
Preset date filterThe preset label, for example "Last 7 days". It must be one of the filter’s presets.
Number range{ "min": 100, "max": 900 }
Values from SQLAn object with sql and columnName (see below)

Values from a SQL query

Use a SQL query when the list is long. Databrain runs the query and uses the values in columnName.

"values": {
  "country": {
    "sql": "SELECT \"name\" FROM \"public\".\"countries\" WHERE is_enabled = true",
    "columnName": "name"
  }
}

The query must be one SELECT (or WITH) statement. On table tenancy, client_id_variable in the query becomes the token’s clientId.

If the SQL query fails or returns no rows, the dashboard loads without that filter by default. Ask Databrain to turn on “Stop the chart when a customer filter breaks” for your company if the filter guards data.

How the name is matched

The key matches the filter’s label or name, and case does not count. Country and country find the same filter.

Show or hide the value in the address bar

isShowOnUrl only matters when the dashboard writes filters to the page URL (options with "isModifyUrl": true). Leave it out or set false to keep token values out of the URL. Set true to show them.

Defaults from the component

global-filter-options on <dbn-dashboard> sets a default value. Viewers can change a default. Use the token when the value must not change. See Filter state.

If something goes wrong

The cards say “Not set up for your account”. Every app filter on the dashboard needs a value in the token. If the token leaves one out, each card refuses to load with the error code METRIC_OUT_OF_SCOPE. Add the filter to params.dashboardAppFilters, or turn off App Filter.

View underlying data is refused for one chart. The token gives a value for an app filter that the server cannot put on that chart’s rows: neither the metric nor the dashboard has that filter on a table the chart reads. The answer is HTTP 403 with code METRIC_OUT_OF_SCOPE, details.reason APP_FILTER_NOT_APPLIED and the filter names in details.missingAppFilters. The message says “Underlying data for this chart cannot be limited by the app filter ...”. Add the filter as an app filter on the metric, or on the dashboard’s filters, on a table the metric reads. Plugins older than 0.17 show only No Data Available for this refusal.

A text search filter is refused in the token. An app filter with a text search operator, such as Like or Not like, takes one nonempty string, or a list with exactly one nonempty string. A longer list is refused: App filter "<name>" has a wrong value: a text search filter takes one nonempty string.

The token request fails with HTTP 400 and code APP_FILTER_PARAM_ERROR. The message tells you why:

  • Invalid dashboard Id: <id> in dashboard appFilter. The dashboard ID is wrong, or the dashboard is not in this data app. Use the ID from the Embeds page, not the name.
  • No filter found: <id> in dashboard appFilter. The dashboard has no filters yet.
  • Invalid dashboard app filter name: <name>. No filter has this label or name, or App Filter is off for it.
  • Invalid select query in dashboard app filter: <name>. The SQL in the value is not one valid SELECT statement.
  • Invalid preset date option in dashboard app filter: <name>. The label is not one of the filter’s presets.

Next, see every token field.