Skip to content

Authentication ​

Chainabit accepts bearer credentials for authenticated API requests. There are two main ways to authenticate:

  1. Browser login — the chainabit auth login command opens a device-approval page in your browser.
  2. Developer tokens — scoped, time-bounded credentials for CI/CD pipelines and automation scripts.

Run chainabit auth login with no flags. The CLI opens your browser automatically.

bash
chainabit auth login

What happens:

  1. The CLI contacts the Chainabit API and receives a short-lived approval code.
  2. Your browser opens the device-approval page with the code pre-filled.
  3. Sign in (or you are already signed in) and click Approve login.
  4. The CLI detects the approval and saves your session in its local configuration.

If the browser does not open automatically, copy the URL printed in the terminal and open it manually.

Non-interactive / headless login ​

Use a developer token (see below) for scripts and CI:

bash
export CHAINABIT_TOKEN=YOUR_DEVELOPER_TOKEN
chainabit workspace list

CLI: Developer Tokens for CI/CD ​

Developer tokens are personal, scoped credentials for supported automation routes. Store one in your job's private environment. Interactive conversation-session operations still require an interactive access token; using the CLI does not change that requirement.

Create a developer token ​

Use a human session to manage developer tokens. Creating a token can require recent verification; a stale session receives 403 STEP_UP_REQUIRED without issuing a token. A developer token cannot create, list, or revoke developer tokens on its owner's behalf. Human sessions can still list and defensively revoke tokens without a new step-up.

bash
chainabit auth keys create "github-actions" --ttl 90 --scope execution:run

When verification is required, the CLI prompts for your account password without displaying it. If the API also requires an authenticator code, complete that step too. The CLI then retries the same key request once. An incorrect password or cancelled verification creates no key.

Run key creation in a terminal before configuring CI. JSON mode never prompts; an explicitly supplied --password-env, --password-file, or --password-stdin can provide verification input. Store the issued scoped key in your CI secret store rather than repeating human verification inside every job.

The raw token is shown once only. Copy it immediately.

API key created: YOUR_DEVELOPER_TOKEN
This key will not be shown again.

To use in CI/CD:
  export CHAINABIT_TOKEN=YOUR_DEVELOPER_TOKEN
  chainabit workspace use <workspace-id>

Optional flags:

bash
chainabit auth keys create "wallet-bot" --ttl 30 --scope wallet:read --scope execution:run
chainabit auth keys create "account-bot" --ttl 30 --account <account-uuid> --scope execution:run

Use the token ​

Set CHAINABIT_TOKEN in your CI environment (GitHub Actions secret, .env file, etc.):

bash
CHAINABIT_TOKEN=YOUR_DEVELOPER_TOKEN chainabit workspace list

The CLI validates cbt_live_... tokens directly against the API. When talking to older servers it can still fall back to the legacy exchange flow automatically.

Manage tokens ​

bash
chainabit auth keys list
chainabit auth keys revoke "$ID"

API: Password Login ​

Direct API access with username/password (requires a captcha token from supported frontends):

curl -X POST "https://api.chainabit.com/api/v1/auth/login" \
  -H "Content-Type: application/json" \
  -H "x-turnstile-token: <captcha-token>" \
  -d '{
    "identifier": "you@example.com",
    "password": "yourPassword123"
  }'

Successful sign-in response:

json
{
  "data": {
    "userId": "uuid",
    "email": "you@example.com",
    "tokens": {
      "accessToken": "eyJ...",
      "refreshToken": "eyJ...",
      "expiresIn": 900,
      "tokenType": "bearer"
    }
  }
}

expiresIn is the access token's lifetime in seconds (900 by default — 15 minutes); use the refresh token to get a new one rather than hardcoding this value. The real response also includes additional account context (subscription, entitlements, profile, workspaces, preferences) for first-party Chainabit clients — treat only userId, email, and tokens as the stable, documented contract; the rest is not versioned for external integrations and may change shape without notice.

Password verification does not always finish sign-in. The server may return 403 MFA_LOGIN_REQUIRED or 403 MFA_RECOVERY_REQUIRED without access or refresh tokens. Complete the offered verification or exceptional recovery in Chainabit. A continuation token is a restricted capability, not an API bearer credential.

For password login through the CLI, these refusals leave credentials unsaved and report chainabit auth login --device as the next command. Follow that instruction only when it is returned; an unrelated API denial does not imply that device login will authorize the operation.

Email confirmation and magic-link receipt do not sign the receiving app in automatically. Generate a private, random 43-character base64url codeVerifier and derive appCodeChallenge = BASE64URL(SHA-256(codeVerifier)). Send the challenge with the email proof to /auth/confirm-email or /auth/magic-link/verify and keep the verifier out of callback URLs and logs.

The response has status: "sign_in_confirmation_required", an API-verified email, challengeId, completionToken, and expiresAt; it contains no session tokens. Show that identity and ask the user to explicitly choose Sign in as that email before calling /auth/mailbox-login/complete with the original verifier and returned capability. Completion returns an authenticated session or the verification/recovery continuation required by the server. The confirmation expires after five minutes and can be completed once.

First-time mailbox confirmation can retire the password supplied before ownership was proven. A final session with passwordSetupRequired: true explains that a new password must be chosen through emailed password recovery. It is not an authentication proof.

If confirmation is interrupted or its sign-in approval expires, the account still exists. Request a fresh sign-in link or use password recovery to choose a new password; registering again does not replace an existing credential. An email account without a password is not necessarily a social-login account. Later mailbox sign-in can still return passwordSetupRequired: true until a password is established.

See the mailbox sign-in flow for the request fields.

API: Password Recovery ​

The emailed password-reset code is exchanged at /auth/exchange-recovery-code for a restricted, five-minute accessToken. Send that grant in the body of /auth/reset-password with the chosen newPassword. It cannot authenticate ordinary API requests and is not an MFA recovery code. Successful replacement returns status: "ok", revokes the former session, and requires sign-in again. Reusing the grant or an expired grant is refused.

Additional Verification ​

The API decides whether each operation requires step-up and which methods are currently usable. Follow its challenge instead of deciding from the account's factor count or adding a password prompt to every mutation. A protected operation returning STEP_UP_REQUIRED needs its bound proof before the same request can proceed.

Ordinary checkout does not require step-up solely because the original sign-in is old. It still requires a live session and access to the selected account; an expired session or a foreign account remains unauthorized.


Use the Access Token ​

curl "https://api.chainabit.com/api/v1/ai/sessions" \
  -H "Authorization: Bearer $TOKEN"

Refresh a Session ​

bash
chainabit auth refresh

Or via API:

curl -X POST "https://api.chainabit.com/api/v1/auth/refresh" \
  -H "Content-Type: application/json" \
  -d '{"refreshToken":"'"$REFRESH_TOKEN"'"}'

Refresh tokens are single-use. Store the new refresh token returned in the response.


Environment Variables ​

VariableDescriptionExample
CHAINABIT_TOKENAccess token or developer token (cbt_live_...)Pre-supply auth without logging in
CHAINABIT_BASE_URLAPI base URLhttps://api.chainabit.com/api/v1
CHAINABIT_WORKSPACE_IDDefault workspace IDAuto-selects workspace

Built with purpose. chainabit.com