keyAPI Authentication

Bluebricks API supports two authentication methods:

  • Long-lived API Tokens - For automated workflows and CI/CD pipelines

  • JWT Tokens - For personal authentication and testing

JWT Tokens

JWT tokens are obtained from the CLI or UI and are ideal for personal testing and development.

Extract JWT from CLI

After running bricks login, extract your JWT token:

token=$(awk '/^token:/ {sub(/token:[[:space:]]*/, ""); print; exit}' ~/.bricks/credentials.yaml)
curl -H "Authorization: ${token}" https://api.bluebricks.co/api/v1/environments

Long-lived API Tokens

Long-lived API tokens are essential for secure server-to-server communication, enabling seamless authentication without frequent renewals.

You can create and manage API tokens through:

Prerequisites

Managing long-lived API tokens requires Admin role

Create via UI

Navigate to Settings > Tokensarrow-up-right in the Bluebricks app to create and manage your API tokens.

API Tokens Settings
circle-exclamation

Create via API

Use the POST Auth Key API to create a long-lived API token:

For first-time creation, use your JWT token to authenticate the request.

circle-exclamation
circle-check

List via API

Use the GET Auth Keys API to list your long-lived API tokens:

Deactivate via API

Use the POST Auth Deactivate Key API to disable long-lived API tokens:

Activate via API

Use the POST Auth Activate Key API to enable long-lived API tokens:

Using API tokens with Bricks CLI

Once you have a long-lived API token, you can use it with the Bricks CLI in three ways:

You can also set the api_key field in ~/.bricks/environment.yaml:

For full details on authentication methods and priority, see CLI Authenticationarrow-up-right.

CI/CD integration

GitHub Actions

Use the Bricks GitHub Actionarrow-up-right to authenticate automated deployments:

Automation scripts

Security best practices

  • Store securely: use environment variables or a secret management system; never hard-code tokens

  • Rotate regularly: create a new key, update your workflows, then deactivate the old one

  • Copy immediately: tokens are only displayed once upon creation

  • Never commit to version control: add secrets to .gitignore and use CI/CD secret stores

Last updated

Was this helpful?