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

# How to Connect

## Step 1: Generate an API Token from MindBridge

To authenticate with the API, you’ll need a Bearer token.

How to generate it:

1. Log into your MindBridge tenant.
2. Navigate to Admin → API (Admins only).
3. Click Generate New Token.
4. Name it (e.g., “Power BI Integration”).
5. Copy the token — it won’t be visible again.

Tokens can be revoked or rotated anytime from the same screen.

## Step 2: Create a Parameter in Power BI for the Token

To securely reference the token in your queries:

1. Open Power BI Desktop.
2. Go to Transform Data → Manage Parameters → New Parameter.
3. Use the following values:

* **Name:** apiToken
* **Type:** Text
* **Current Value:** Paste your token here — no “Bearer ” prefix

### Security Notes

The token is stored in plain text within the `.pbix` file — limit access accordingly.

For production or shared reports, publish to Power BI Service and configure a Gateway with securely stored credentials.

For enterprise deployments, consider using Azure Key Vault integration to securely manage secrets (Power BI Premium feature).

## Step 3: Create a Basic Test Query to Validate the Connection

This lightweight test will confirm that Power BI can connect to the MindBridge API.

1. Go to Home → Transform Data.
2. In the Power Query Editor, click Advanced Editor.
3. Paste the following M code, but replace `yourcompany` in the URL with the subdomain of your own MindBridge tenant.

```m theme={null}
let
    token = "Bearer " & apiToken,
    url = "https://yourcompany.mindbridge.ai/api/v1/engagements/query?page=0&size=1",

    response = Web.Contents(url, [
        Headers = [
            #"Authorization" = token,
            #"Content-Type" = "application/json"
        ],
        Content = Text.ToBinary("{}")
    ]),

    json = Json.Document(response)
in
    json
```

You should see a JSON response — typically one item or an empty content array — confirming the connection works.

## Step 4: Set Authentication Method to Anonymous

To ensure Power BI uses your token rather than prompting for login:

1. Go to File → Options and settings → Data source settings.
2. Select or add your API domain (e.g., `https://yourcompany.mindbridge.ai`).
3. Click Edit Permissions.
4. Set Authentication Method to Anonymous.
5. Click OK.
