> For the complete documentation index, see [llms.txt](https://brightwind.gitbook.io/brighthub-user-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://brightwind.gitbook.io/brighthub-user-docs/api-reference/how-to-use-api-keys.md).

# How to use API Keys

### 🔑 How to Use Your API Key to Access BrightHub APIs

This page shows you how to **generate an ID Token** using your **API Keys**.\
You will need this **ID Token** to authenticate and successfully call any BrightHub API.

If you don’t have an API Key yet, first create one by clicking the **Profile icon** in the top-right corner, select **“Account Settings”**, then navigate to the **Settings** tab and configure your **API Keys** from **Manage API Keys.**\
[API Key Management](/brighthub-user-docs/api-reference/api-key-management.md)

Once you have your **Client ID** and **Client Secret**, follow these steps:

### Option 1: Generate ID Token from GitBook

**Steps to Generate Your ID Token**

1. **Call the “Generate Authentication Token” endpoint below**\
   This will allow you to get your ID Token.
2. **Run the request**\
   Click **“Test it”**&#x20;
3. **Enter your API Key details using Basic Authentication**
   * **Client ID** →  use as the *Username*
   * **Client Secret** →  use as the *Password*
4. **Copy the `id_token` from the response**\
   This `id_token` is what you will use when calling BrightHub APIs (paste it into the **Authorization** header as a **Bearer token**).\
   Example API that requires `id_token` -> [Measurement Location API](/brighthub-user-docs/api-reference/measurement-location-api.md)

> 💡 Your ID Token is valid for a limited time. Once it expires, simply generate a new one using the same steps.

## Generate Authentication Token

> Generates an \*\*ID Token\*\* using your API Keys to authenticate brighthub APIs.  \
> Use \*\*Basic Authentication\*\*, where:  \
> • username = Client ID  \
> • password = Client Secret  <br>

```json
{"openapi":"3.0.3","info":{"title":"Brighthub Authentication API","version":"1.0.2"},"servers":[{"url":"https://api.brighthub.io","description":"Production Environment"}],"security":[{"basicAuth":[]}],"components":{"securitySchemes":{"basicAuth":{"type":"http","scheme":"basic","description":"Use **Basic Auth** where:\n- Username = Client ID\n- Password = Client Secret\n"}}},"paths":{"/auth/token":{"post":{"summary":"Generate Authentication Token","description":"Generates an **ID Token** using your API Keys to authenticate brighthub APIs.  \nUse **Basic Authentication**, where:  \n• username = Client ID  \n• password = Client Secret  \n","tags":["Authentication"],"requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"schema":{"type":"object","required":["grant_type"],"properties":{"grant_type":{"type":"string"}}}}}},"responses":{"200":{"description":"ID Token generated successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"access_token":{"type":"string"},"id_token":{"type":"string"},"token_type":{"type":"string"},"expires_in":{"type":"integer"}}}}}},"400":{"description":"Invalid request."},"401":{"description":"Unauthorized – invalid Client ID or Client Secret."}}}}}}
```

### Option 2: Generate Your ID Token Using Postman

If you already use **Postman** to call BrightHub APIs, you can easily generate and attach your ID Token directly from Postman.

\
**Steps to Generate Your ID Token**

1. **Open your API request in Postman**
   * Go to the request you want to authenticate.<br>
2. Click on the **Authorization** tab.<br>
3. Under **Type**, select **OAuth 2.0**<br>
4. Scroll to **Configure New Token** and fill in the fields exactly as below:

| Field                     | Value                                 |
| ------------------------- | ------------------------------------- |
| **Token Name**            | Any name (e.g., `BrightHub-Token`)    |
| **Grant Type**            | Client Credentials                    |
| **Access Token URL**      | <https://api.brighthub.io/auth/token> |
| **Client ID**             | Your API Key **Client ID**            |
| **Client Secret**         | Your API Key **Client Secret**        |
| **Client Authentication** | Send as **Basic Auth header**         |

5. Click **Get New Access Token**

<figure><img src="/files/NbbrCdvH6zGCgQZiK348" alt="" width="563"><figcaption></figcaption></figure>

<p align="center"><sup>Figure 1: Getting new Access Token</sup></p>

6. When the token appears, click **Use Token**

<figure><img src="/files/34hQEtB1mk7HPZ0RCwLm" alt="" width="563"><figcaption></figcaption></figure>

<p align="center"><sup>Figure 2: Token Details</sup></p>

7. Scroll back up to set the Current Token section and set the **Use** **Token Type** to 'ID token' and set the **Header Prefix** to 'Bearer'.

<figure><img src="/files/NbbrCdvH6zGCgQZiK348" alt="" width="563"><figcaption></figcaption></figure>

<p align="center">Figure 3: Current Token</p>

8. Send the request again — it should now be authenticated ✅

> 💡 Once configured, Postman will remember this token and **auto-attach it** to future requests — until it expires.\
> If expired, simply click **Refresh** or **Get New Access Token** again.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://brightwind.gitbook.io/brighthub-user-docs/api-reference/how-to-use-api-keys.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
