# Authentication

### JWT Bearer  token

With each request to the API, we need to send an authorization token. This token is a JWT Bearer token.&#x20;

The first step in creating JWT tokens is to create a secret key that will be used to sign the tokens. For this, we need to generate them from the Brief App on Team Settings > API credentials. The secret key should be kept private and should not be shared with anyone.

For the generation of the token, we need to have a JSON payload in which to add the public key. The payload is the data that is encoded in the token.  For example, the payload for a request might look like this:

```json
// payload
{
    "clientId": '...publickey...,
    "iat": 1516239022
}
```

The payload needs to be signed using the secret key. This can be done using a library like `jsonwebtoken`. The resulting token will be a long string that can be passed to the client.

```javascript
const jwt = require('jsonwebtoken');
const token = jwt.sign({ payload }, secretKey);
```

The client will then send the token back to the server with each request. The server can then validate the token by decoding it and checking the signature using the same secret key.

In the REST API, you can generate the token using [Auth](/public-api/rest-api/auth.md) route.


---

# Agent Instructions: 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://docs.thebrief.ai/public-api/authentication.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.
