API 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$token = (Get-Content "$HOME\.bricks\credentials.yaml" | Select-String -Pattern '^token:' | ForEach-Object { $_ -replace '^token:\s*', '' })
curl -H "Authorization: $token" https://api.bluebricks.co/api/v1/environmentsLong-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:
UI - Settings > Tokens
API - Use the Auth endpoints described below
Prerequisites
Managing long-lived API tokens requires Admin role
Token permissions
API tokens have a fixed set of permissions defined at the platform level. They do not inherit the creating user's role.
API tokens cannot be used to:
Invite or manage users
Change organization settings
Create, view, or manage API keys
These operations require JWT authentication (via bricks login or the UI).
For the full role and permission matrix, see Roles and Permissions.
Create via UI
Navigate to Settings > Tokens in the Bluebricks app to create and manage your API tokens.

Important: API tokens are only displayed once upon creation. Make sure to copy and store your token securely before closing the dialog.
Create via API
Use the POST Auth Key API to create a long-lived API token:
The name field is optional. If omitted, it defaults to "default".
For first-time creation, use your JWT token to authenticate the request.
Important: The API token is only returned once in the response. Make sure to copy and store it securely.
Once you have a long-lived API token, it can authenticate requests to any endpoint within its permission scope.
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 Authentication.
CI/CD integration
GitHub Actions
Use the Bricks GitHub Action 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
.gitignoreand use CI/CD secret stores
Last updated