> For the complete documentation index, see [llms.txt](https://docs.thebrief.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.thebrief.ai/public-api/authentication.md).

# Authentication

#### JWT Bearer token

Every request to the API carries a JWT Bearer token: `Authorization: Bearer <token>`.

You sign the token yourself with your API key's secret. Create the key in The Brief under **Team settings › API credentials**: you get a Client ID and a Secret key. Keep the secret private.

The token's payload:

```json
{
  "clientId": "<your Client ID>",
  "iat": 1794480000
}
```

* **`clientId`** (required): your key's Client ID.
* **`iat`** (required): when you signed the token, in **seconds** since the Unix epoch, not milliseconds.
* **`exp`** (recommended): when the token expires, in seconds. At most one hour after `iat`.

**Sign a new token for each request, or at least once an hour.** We accept a token for 1 hour after its `iat`, allowing up to 60 seconds of clock difference between your servers and ours. A token without `iat`, with an `iat` in the future, or older than an hour is refused.

```javascript
const jwt = require('jsonwebtoken');

// jsonwebtoken sets iat to the current time, in seconds.
const token = jwt.sign({ clientId }, secretKey, { expiresIn: '1h' });

await fetch(url, { headers: { Authorization: `Bearer ${token}` } });
```

#### What a key can do

An API key acts on behalf of the team member who created it:

* It stops working once its creator is no longer the team owner or a member of the team.
* It can only reach what its creator can reach in The Brief.
* Only a key created by the team owner, or by a member with the **Manage team** permission (such as an Admin), can use **The Brief** access (the public API) or sign white-label login tokens. Any member can create a key with **Zapier** or **Figma** access.

In the REST API, you can also get a token from the [Auth](https://docs.thebrief.ai/public-api/rest-api/auth) route.
