> For the complete documentation index, see [llms.txt](https://bluebricks.co/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bluebricks.co/docs/bricks-cli/authentication/authenticate-using-long-lived-tokens.md).

# Authenticate Using Long-Lived Tokens

Developers can use [long-lived tokens](https://bluebricks.co/docs/api/authenticate/authentication) to authenticate the CLI and integrate [**bricks CLI**](/docs/bricks-cli/bricks-cli.md) commands into scripts and automation workflows, such as CI/CD pipelines or AI operations.

This guide explains how to configure a long-lived token as the authentication key for the CLI.

## Generate a Long-Lived Token

Ensure you have a valid long-lived token. [Read here to learn how to create tokens](https://bluebricks.co/docs/api/authenticate/authentication).

Once created, your token will look like this:

```
{
    "api_key": "bbx_2b52642255....4ffd"
}
```

## Embed the Token in the Configuration File

The **bricks CLI** uses various configuration files. The `credentials.yaml` file stores your authentication key and identity.

To authenticate using the long-lived token:

1. Open the `credentials.yaml` file located at:

```
$HOME/.bricks/credentials.yaml
```

2. Update the file with the following values:
   * Set `token` to the long-lived token.
   * Set `userid` to the value `api_key`.

Your updated `credentials.yaml` should look like this:

```
token: Bearer bbx_2b52642255....4ffd
userid: api_key
```

You’re now ready to use **bricks CLI** with your long-lived token for automation and scripting!
