> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usedatabrain.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get an guest token

> This page will help you to get a guest token which you can use to access the dashboard metrics in your app using the databrain plugin.

<Steps>
  <Step title="Open API Token Settings">
    Go to the Databrain app settings and then click on the <b>API Token</b> tab.
  </Step>

  <Step title="Locate your API Key">
    Find the API Key which has permission to access metrics and dashboards.

    <Frame>
      <img src="https://mintcdn.com/databrainlabs-bef6850a/6oHBukEqmXlHScVq/images/guides/image-gagt1.png?fit=max&auto=format&n=6oHBukEqmXlHScVq&q=85&s=b994468ed6f91331a4fa9f18a1f53865" width="1366" height="607" data-path="images/guides/image-gagt1.png" />
    </Frame>
  </Step>

  <Step title="Send POST request from Postman">
    Open your Postman App and send a POST request to the URL -\
    `https://api.usedatabrain.com/api/v2/guest-token/create`

    <Frame>
      <img src="https://mintcdn.com/databrainlabs-bef6850a/6oHBukEqmXlHScVq/images/guides/image-gagt2.png?fit=max&auto=format&n=6oHBukEqmXlHScVq&q=85&s=105f1b77cf6b731bc41c369b490388f7" width="1022" height="689" data-path="images/guides/image-gagt2.png" />
    </Frame>
  </Step>

  <Step title="Set Bearer Token">
    Click on the <b>Authorization</b> tab, select type as <b>Bearer Token</b>, and paste the API Key copied from the Databrain App’s API Token tab.
  </Step>

  <Step title="Set raw JSON body in Postman">
    In the Body tab of Postman, choose <b>raw</b> and <b>JSON</b>.\
    You’ll need a `clientId` which should come from your user’s session—since this API will be called from your app ideally.

    <Frame>
      <img src="https://mintcdn.com/databrainlabs-bef6850a/6VX-l-6j92sug0A2/images/guides/image-postman-body-raw1.png?fit=max&auto=format&n=6VX-l-6j92sug0A2&q=85&s=a4d3196c739f43376031d86b480b8012" width="981" height="485" data-path="images/guides/image-postman-body-raw1.png" />
    </Frame>
  </Step>

  <Step title="Advanced JSON body with RLS (Row Level Security)">
    The minimum required JSON structure is:

    ```json theme={"dark"}
    {
      "dataAppName": "your data app name",
      "clientId": "Your client or user Id for which you are creating this guest token"
    }
    ```

    If you want to add some Row Level of Security settings then in params you can also add another key “rlsSettings” It is an array of objects which has “metricId” - the id of the metric you want to have rls settings enabled for along with the key “values” which is an object of rls condition name and its value pair filter for the particular metric.

    Now our new json body structure would be -

    ```json theme={"dark"}
    {
      "dataAppName": "your data app name",
      "clientId": "Your client or user Id for which you are creating this guest token",
      "params": {
        "rlsSettings": [
          {
            "metricId": "The id of the metric you want to have rls filters",
            "values": {
              "paid_orders": true,
              "amount": 500
            }
          }
        ]
      }
    }
    ```

    If you use SQL query to generate the metric data and want to add metric filters but don't want end users to use them then you can add **appFilters**.

    Please refer to this article to know more about app filters.

    <Card title="App filter" icon="arrowRight" href="https://docs.usedatabrain.com/guides/filters/app-filter">
      Learn how to use app-level filters to restrict data visibility at runtime.
    </Card>

    To add app filters it's the same process as rls settings. Here you have to add another key "appFilters" and then you can specify the value same as rls settings.

    ```json theme={"dark"}
    {
      "dataAppName": "your data app name",
      "clientId": "Your client or user Id for which you are creating this guest token",
      "params": {
        "appFilters": [
          {
            "metricId": "The id of the metric you want to have app filters",
            "values": {
              "paid_orders": true,
              "amount": 500,
              "country": ["USA", "CANADA"]
            }
          }
        ]
      }
    }
    ```
  </Step>

  <Step title="Send the Request and Retrieve the Token">
    Click on the **Send** button in Postman. In the response, you will receive the generated token.\
    Copy this token and use it within your Databrain plugin configuration.
  </Step>
</Steps>
