> ## 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.

# End User Metric Creation

1. **Create a Datamart**

Create a Datamart in "Data Studio" page. Kindly refer the below link on how to create datamarts:

<Card title="Create a Datamart" description="This guide provides a straightforward process for creating a datamart in Databrain, allowing users to efficiently manage and analyze data." href="https://docs.usedatabrain.com/guides/datasources/create-a-datamart" />

2. **Create a Workspace with Datamart connection**

<Frame>
  <img src="https://mintcdn.com/databrainlabs-bef6850a/4wZlBKZskJWgCs2c/images/developer-docs/image-eumc1.png?fit=max&auto=format&n=4wZlBKZskJWgCs2c&q=85&s=e556adf5776d65230a48de49e4e94752" width="768" height="354" data-path="images/developer-docs/image-eumc1.png" />
</Frame>

For more details, kindly refer the below link:

<Card title="Workspace" description="Steps to Set Up and Use Multi-Datasource Switching in Your Dashboard." href="https://docs.usedatabrain.com/guides/workspace/multi-datasource-workspace" />

3. **Create a Dashboard with few defined metrics**

<Frame>
  <img src="https://mintcdn.com/databrainlabs-bef6850a/4wZlBKZskJWgCs2c/images/developer-docs/image-eumc2.png?fit=max&auto=format&n=4wZlBKZskJWgCs2c&q=85&s=3d405cb826c4930425802634ab416369" width="768" height="357" data-path="images/developer-docs/image-eumc2.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/databrainlabs-bef6850a/4wZlBKZskJWgCs2c/images/developer-docs/image-eumc3.png?fit=max&auto=format&n=4wZlBKZskJWgCs2c&q=85&s=8439c27b47de8561e1ac4d0ab1dcb68c" width="768" height="353" data-path="images/developer-docs/image-eumc3.png" />
</Frame>

For more details, kindly refer the below link:

<Card title="Create a Dashboard" description="Dashboards in Databrain allow you to visualize and organize your data effectively within a specific workspace. This guide walks you through the simple process of creating a dashboard." href="https://docs.usedatabrain.com/guides/workspace/create-a-dashboard" />

4. **Create a DataApp**

<Frame>
  <img src="https://mintcdn.com/databrainlabs-bef6850a/rztAaW4K131jq2rk/images/developer-docs/image-eumc5.png?fit=max&auto=format&n=rztAaW4K131jq2rk&q=85&s=749f15ddf3a86e5f3b9eb50a43fa0e28" width="768" height="359" data-path="images/developer-docs/image-eumc5.png" />
</Frame>

For more details, kindly refer the below link:

<Card title="Create a Data App" description="Dashboards in Databrain allow you to visualize and organize your data effectively within a specific workspace. This guide walks you through the simple process of creating a dashboard." href="https://docs.usedatabrain.com/guides/workspace/create-a-dashboard" />

5. **Create an Embed Type using either dashboard or metric**

* Navigate to the Data App.
* In the "Embed Info" section, create an embed type using workspace name, embed type: dashboard or metric, name of dashboard or metric.

<Frame>
  <img src="https://mintcdn.com/databrainlabs-bef6850a/rztAaW4K131jq2rk/images/developer-docs/image-eumc4.webp?fit=max&auto=format&n=rztAaW4K131jq2rk&q=85&s=4723e4a388a4993541078339c111eb6c" width="688" height="322" data-path="images/developer-docs/image-eumc4.webp" />
</Frame>

6. **Generate API Token**

In the "API Token" section, generate the API token by specifying the name of company and description (optional)

<Frame>
  <img src="https://mintcdn.com/databrainlabs-bef6850a/rztAaW4K131jq2rk/images/developer-docs/image-eumc6.webp?fit=max&auto=format&n=rztAaW4K131jq2rk&q=85&s=667a1c78bb3ae6bb8da04fb01f44dc93" width="688" height="321" data-path="images/developer-docs/image-eumc6.webp" />
</Frame>

7. **Configure options in Access control section**

* Navigate to the Data App.
* In the "Access Control" section, enable **Metric Creation** for the embed.

<Note>
  Metric creation is controlled at three levels, in priority order:

  1. **Guest token** — if the token sets `permissions.isDisableMetricCreation: true`, metric creation is off no matter what else is configured.
  2. **Data App Access Control** — the server-side setting you enable in this step.
  3. **Embed component** — `options.disableMetricCreation` on `dbn-dashboard` hides the UI client-side.
     There is no `isAllowMetricCreation` embed prop — the component option is `disableMetricCreation`.
</Note>

<Frame>
  <img src="https://mintcdn.com/databrainlabs-bef6850a/rztAaW4K131jq2rk/images/developer-docs/image-eumcc7.png?fit=max&auto=format&n=rztAaW4K131jq2rk&q=85&s=c66a66fc4e856f5cec314b43c0bc0ecc" width="768" height="359" data-path="images/developer-docs/image-eumcc7.png" />
</Frame>

8. **Create Guest token by passing Client ID and DataApp Name**

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

**Cloud Databrain:**

```http theme={"dark"}
POST https://api.usedatabrain.com/api/v2/guest-token/create
```

**Self-hosted Databrain:**

```http theme={"dark"}
POST <SELF_HOSTED_URL>/api/v2/guest-token/create
```

## Generating GUEST TOKEN for your Dashboard/Metric Component

### Headers

| Name            | Type   | Description        |
| --------------- | ------ | ------------------ |
| Authorization\* | String | Bearer (API Token) |

### Request Body

| Name           | Type   | Description                                                                                                                              |
| -------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| dataAppName\*  | String | Your Data App 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: `appFilters`, `rlsSettings`, `userIdentifier`, `allowedEmbeds` — see [Token Body](/developer-docs/helpers/token-body) |
| expiryTime     | Number | In milliseconds. If omitted, the token never expires                                                                                     |
| datasourceName | String | Datasource name from Data Studio (\*important and supported in multi-datasource connection in workspace)                                 |

**Example Response: 200 OK "token": "..."**

```json theme={"dark"}
when the response is successful it returns a token that you can pass to the frontend.
```

<p>When the response is successful it returns a token that you can pass to the frontend.</p>

### Simple Request Body

```json theme={"dark"}
{
  "clientId": "Vaccine",
  "dataAppName": "Procurement App"
}
```

Once you acquire the guest token, you can seamlessly pass it to your frontend application, where it can be integrated with the <Link href="https://docs.usedatabrain.com/developer-docs/">web component</Link>.

9. **End User Metric Creation / Updation**

**Metric Creation**

* Click on the "+Create Metric" button near the settings icon

<Frame>
  <img src="https://mintcdn.com/databrainlabs-bef6850a/rztAaW4K131jq2rk/images/developer-docs/image-eumcc8.png?fit=max&auto=format&n=rztAaW4K131jq2rk&q=85&s=3f27f4777d44e62822c62b4d6a94546d" width="768" height="357" data-path="images/developer-docs/image-eumcc8.png" />
</Frame>

* Drag and drop necessary dimensions and measures to create the metric
* Then, click on "Save" icon at the top right corner and specify metric details to save the metric to dashboard

<Frame>
  <img src="https://mintcdn.com/databrainlabs-bef6850a/rztAaW4K131jq2rk/images/developer-docs/image-eumc9.webp?fit=max&auto=format&n=rztAaW4K131jq2rk&q=85&s=9b2dbf36829d9b8da75de0b27453ce5d" width="688" height="322" data-path="images/developer-docs/image-eumc9.webp" />
</Frame>

**Metric Updation**

* View the metric in full screen and click on the "Edit Metric" button

<Frame>
  <img src="https://mintcdn.com/databrainlabs-bef6850a/4wZlBKZskJWgCs2c/images/developer-docs/image-eumc10.png?fit=max&auto=format&n=4wZlBKZskJWgCs2c&q=85&s=ac53f600682066930da0c490eef55ea0" width="768" height="358" data-path="images/developer-docs/image-eumc10.png" />
</Frame>

* Update the metric according to your requirements and save it to dashboard

<Frame>
  <img src="https://mintcdn.com/databrainlabs-bef6850a/4wZlBKZskJWgCs2c/images/developer-docs/image-eumc11.webp?fit=max&auto=format&n=4wZlBKZskJWgCs2c&q=85&s=72d1de850b5eb52f39008005d1d7380c" width="688" height="322" data-path="images/developer-docs/image-eumc11.webp" />
</Frame>
