# 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!


---

# 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://bluebricks.co/docs/bricks-cli/authentication/authenticate-using-long-lived-tokens.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.
