🛠️
Developer docs
Start BuildingGuides
  • ✨Getting Started
  • 🎛️Self Hosted Config
  • ✍️SSO Login
    • Saml Identity Provider (Idp)
    • Oidc Identity Provider (Idp)
  • 🎞️Framework Specific Guide
    • ⚛️Reactjs
    • ⚛️Nextjs
    • ⚛️Vuejs
    • ⚛️Angular
    • ⚛️Svelte
    • ⚛️Solid
    • ⚛️Vanilla JS
  • ℹ️Token
  • 🏛️Multi-Tenant Access Control
  • Embed using iFrame (Not Recommended approach)
  • 🔑License Key Validation for Self-Hosted App
  • Test
  • 👩‍💻Helpers
    • ✳️Token Body
    • ✅Options
      • Custom Fiscal Year filter setup in DataBrain
    • 🈂️Server Event
    • Embed Functions
    • Override Language
    • ✈️Embedding Architecture
    • ✈️LLM Architecture
    • ✨LLM Connectors
      • Open AI
      • Claude AI
      • Azure Open AI
      • Llama
      • Mixtral
    • 🆔Dashboard ID
    • 🆔Metric ID
    • 🆔API Token
    • 🆔End User Metric Creation
    • Embedding APIs
      • Sync Datasource
  • Metric App Filter
  • Dashboard App Filter
  • Chat Mode
    • Step 1: Create Datamart and Workspace
    • Step 2: Create Data App and Embed ID
  • ✨Solutions Alchemy
    • Dashboards for Client Groups
    • Dashboard for Multiple Clients
    • Embedding: Role based Dashboard Filtering
    • Localized Currency Symbols
    • Manage Metrics
Powered by GitBook
On this page
  • Quick start (simple use case):
  • Request Body Examples:
  • Dashboard App Filters:
  • Datasource [Workspace with Multi Datasource connection]:
  • Hide Dashboard Filters:
  • Dashboard Permissions

Token

PreviousVanilla JSNextMulti-Tenant Access Control

Last updated 3 months ago

To obtain a guest token from DataBrain, utilize our REST API from your backend system. Each request will generate a unique guest token, ensuring security and flexibility.

Once you acquire the guest token, you can seamlessly pass it to your frontend application, where it can be integrated with the .

that should be passed in the headers in these requests.


Quick start (simple use case):

When you need a guest token that you want to use across dashboards and metrics. All you have to do is pass clientId, workspaceName. If expiryTime is not passed, the token will not expire.

Cloud Databrain:

POST https://api.usedatabrain.com/api/v1/guest-token/create

Self-hosted Databrain:

POST <SELF_HOSTED_URL>/api/v1/guest-token/create

Generating GUEST TOKEN for your Dashboard/Metric Component.

Headers

Name
Type
Description

Authorization*

String

Request Body

Name
Type
Description

workspaceName*

String

Your Workspace Name

clientId*

String

Client ID for whom this guest token is generated. ("clientId": "None", if no tenancy is selected for connected datasource/datamart)

params

Object

Additional Params: dashboard appFilters

expiryTime

Number

In milli seconds

datasourceName

String

datasource name from data studio (important* and supported in multi datasource connection in workspace)

when the response is successful it returns a token that you can pass to the frontend.

When invalid parameter is passed, you will get this error. The "code" refers to the error code. Different types of error code that are possible are: 'INVALID_REQUEST_BODY'

'CLIENT_ID_ERROR'

'WORKSPACE_ID_ERROR'

'DASHBOARD_PARAM_ERROR'

'APP_FILTER_PARAM_ERROR'

'RLS_SETTINGS_PARAM_ERROR'

'INTERNAL_SERVER_ERROR'

When the correct API key is not passed in the headers, you will get this error

Request Body Examples:

Simple Request Body:

{
  "clientId": "id", //"None" if no tenancy available 
  "workspaceName": "workspacename"
}

Request Body with Dashboard Specified:

{
  "clientId": "id", //"None" if no tenancy available 
  "workspaceName": "workspacename",
  "params" : {
     "dashboard": {
       "id": "dashboardid"
     }
   }
}

Request Body with App Level Metric Filter:

{
  "clientId": "id", //"None" if no tenancy available 
  "workspaceName": "workspacename",
  "params" : {
     "appFilters": [{
			“metricId”: “The id of the metric you want to have app filters”,
			“values”: {
				“paid_orders”: true,
				“amount”: 500,
				“country”: ["USA", "CANADA"] || "USA" // based on filter variant(select or multi select)
				 {
            				"sql": "SELECT \"name\" FROM \"public\".\"countries\" WHERE isEnabled=true",
            				"columnName": "name"
          			}
	}
		}]
   }
}

A sample Postman Collection:

Dashboard App Filters:

Request Body with Dashboard filters:

{
  "clientId": "id", //"None" if no tenancy available 
  "workspaceName": "workspacename",
  "params": {
    "dashboardAppFilters": [
      {
        "dashboardId": "dashboard-id",
        "values": {
          // single string
          "name": "Eric",
          // multi select
          "country": ["USA", "CANADA"] || "USA", || // based on filter variant(select or multi select)
          {
            "sql": "SELECT \"name\" FROM \"public\".\"countries\" WHERE isEnabled=true",
            "columnName": "name"
          } 
          // date-picker
          "timePeriod": { "startDate": "2024-01-01", "endDate": "2024-3-23" },
          // range
          "price": { "min": 1000, "max": 5000 }
        }
        "isShowOnUrl": true, // true/false
      }
    ]
  }
}

When you disable the isShowOnUrl the filter will not visible to end user as search params on URL.

Datasource [Workspace with Multi Datasource connection]:

{
  "clientId": "id", //"None" if no tenancy available 
  "workspaceName": "workspacename",
  "datasourceName":"data source name" 
}

datasourceName is available in app data studio tab

Hide Dashboard Filters:

To hide dashboard filters in an embedded dashboard

{
    "clientId": "id", //"None" if no tenancy available 
    "workspaceName": "workspacename",
    "params":{
        "hideDashboardFilters": ["filter 1", "filter 2"] // name of dashboard filters to hide
    }
}

Dashboard Permissions

To enable or disable few dashboard permissions from backend

{
    "clientId": "id", //"None" if no tenancy available 
    "workspaceName": "workspacename",
    "permissions": {
       "isEnableArchiveMetrics": true, // true or false
       "isEnableManageMetrics": true,  // true or false
       "isEnableMetricUpdation": true, // true or false
       "isEnableCustomizeLayout": true,// true or false
       "isEnableUnderlyingData": true, // true or false
       "isEnableDownloadMetrics": true, // true or false
    },
}

Error Codes:

  • 'AUTHENTICATION_ERROR'

  • 'INVALID_REQUEST_BODY'

  • 'CLIENT_ID_ERROR'

  • 'WORKSPACE_ID_ERROR'

  • 'DASHBOARD_PARAM_ERROR'

  • 'APP_FILTER_PARAM_ERROR'

  • 'RLS_SETTINGS_PARAM_ERROR'

  • 'INTERNAL_SERVER_ERROR'

Bearer

ℹ️
web component
Create API key from Databrain's dashboard
API TOKEN
App filterA metric level filter designed specifically for controlling access to individual metrics. Unlike general RLS settings. It restricts access without requiring end user input or control.
2KB
Request.json