# Mode

## Before you start

To connect Mode to Select Star, you will need...

* Admin access to your Mode account.
* A paid Mode plan (required for API token generation).
* If you want to see Mode reports in personal spaces and calculate popularity based on the last 90 days of user activity, you will need credentials for your Mode Discovery Database. Learn more about getting access to Mode Discovery Database [here](https://mode.com/developer/discovery-database/introduction/).

Complete all of the following steps to see Mode metadata, lineage, and popularity in Select Star.

1. [Create an API Access Token](#1.-create-an-api-access-token)
2. [Connect Mode API to Select Star](#2.-connect-mode-to-select-star)
3. [Connect Mode Discovery Database to Select Star](#3.-connect-mode-discovery-database)

## 1. Create an API Access Token

To enable integration with Mode, you can use either Workspace API tokens or Member API tokens. However, we strongly recommend using Workspace API tokens as they provide comprehensive access and help avoid permission issues when organizational structures change.

### Workspace API Tokens

Workspace API tokens are designed for programmatic management of your Mode workspace. They mimic Admin access to the Workspace and are ideal for tasks such as archiving inactive reports or managing schedules. Only Admins can create and manage these tokens.

To generate a Workspace API token:

1. Navigate to **Workspace Settings** > **Features** > **API Keys** > **Workspace keys**.
2. Click "Create API Key" and provide a display name.
3. Save "Key ID" and "Secret" values, as you will need them in [step 2](#2.-connect-mode-to-select-star).

### Member API Tokens

Member API tokens are intended for individual use cases, such as updating specific reports or managing collections. These tokens mimic the individual user's access to resources in the Workspace.

To generate a Member API token:

1. Admins must enable Member API tokens in **Workspace Settings** > **Features** > **API Keys** > **Member keys**.
2. Users can then create their own tokens in **Workspace Settings** > **Personal** > **My API Keys**.
3. Save "Key ID" and "Secret" values, as you will need them in [step 2](#2.-connect-mode-to-select-star).

### Important Notes

* API tokens expire after 90 days by default.\
  – Using a Member API token allows you to restrict access to specific collections within Select Star, but it introduces additional complexity to the permissions model.
* Ensure you securely store both the Token (Key ID) and Secret when creating any API token.
* For more details, refer to [Mode's API token documentation](https://mode.com/help/articles/api-tokens).

## 2. Connect Mode API to Select Star

Go to the Select Star **Settings**. Click **Data** in the sidebar, then **+ Add** to create a new Data Source.

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-1b5ef3716637dedbfa0eb69326a83270b0773b0b%2FAdd_Data_Source_Settings.gif?alt=media)

Choose **Mode** in the Source Type dropdown and provide the following information:

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-ab6975b8c1f4d7a3f4000a1332859a0db0c71384%2FScreen%20Shot%202021-11-09%20at%203.55.07%20PM.png?alt=media\&token=a7d9e6cb-ec09-4878-978f-8644e2992fd2)

* **Display Name:** This value is `Mode` by default, but you can override it if desired.
* **API access token:** The `Key ID` value from the API token created in Mode.
* **Token secret:** The `Secret` value from the API token created in Mode.
* **Organization:** The name of your Mode organization. It'll be the part of the url after `app.mode.com/home/`
* **DB Connection:** The database you are running Mode on top of, such as Snowflake or BigQuery.
* **DB Username:** The name of the service account user that runs mode queries in your DB Connection. It is not a Select Star service account. This is used to identify which queries Mode runs so that Select Star can generate lineage between the database and Mode.

Click the **Connect** button.

{% hint style="success" %}
You must ensure DB Connection and DB Username are set so we can calculate column-level lineage from your DWH to Mode dashboards. You can also verify wether or not the connection has been set by going to [**Settings > Data**](https://app.selectstar.com/admin/data) **> Mode > Connections**.
{% endhint %}

## 3. Connect Mode Discovery Database

{% hint style="info" %}
This step is optional, but **highly recommended** if you want to see Mode reports in personal spaces and to calculate popularity scores based on the last 90 days of user activity.

To learn how to get the Snowflake credentials for Mode Discovery Database, see Mode's instructions [here](https://mode.com/developer/discovery-database/introduction/).
{% endhint %}

To skip this step, click the **Next** button.

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-445b0a4357b0ec45828acd823e5712ef8768af6a%2FScreen%20Shot%202021-11-09%20at%203.55.38%20PM.png?alt=media\&token=c87025bd-c895-42fb-a005-63563beb3f05)

You'll need the following information:

* **Account:** Your Mode Discovery Database account name.
* **Username:** Your Mode Discovery Database username.
* **Password:** Your Mode Discovery Database password.
* **Role:** By default, this value is `PUBLIC`.
* **Warehouse:** The name of your Mode Discovery Database. By default, this value is `WAREHOUSE_XS_MODE`.
* **Database:** By default, this value is `MODE`.
* **Schema:** By default, this value is `ORGANIZATION_USAGE`.

When you have entered the information, click **Next**.

Your metadata should start loading automatically. Please allow 24-48 hours to completely generate popularity and lineage.

When the sync is complete, you'll be able to explore Mode in Select Star. See the link below for more information on Mode in Select Star.

{% content-ref url="../learning-data/getting-started-mode" %}
[getting-started-mode](https://docs.selectstar.com/learning-data/getting-started-mode)
{% endcontent-ref %}
