Authenticate Requests
CLI: Interactive Browser Login
chainabit auth loginOpens a device-approval page in your browser. Sign in and click Approve. Done.
Check who you are logged in as:
chainabit auth whoamiPrint the current token (for piping):
export TOKEN=$(chainabit auth token)CLI: CI/CD with Developer Tokens
Create a token once (shown once — copy it immediately):
Token management requires a human session. Creating a token may return 403 STEP_UP_REQUIRED when recent verification is needed; no token is issued by that refusal. Developer-token credentials cannot manage other developer tokens. Ordinary human-session listing and defensive revocation remain available without a new step-up.
chainabit auth keys create "github-actions" --ttl 90 --scope execution:run
# → YOUR_DEVELOPER_TOKENUse it in your pipeline:
export CHAINABIT_TOKEN=YOUR_DEVELOPER_TOKEN
chainabit workspace list --jsonA developer token is not interchangeable with an interactive access JWT. Workspace discovery is a supported route; general AI session listing requires a human session. The execution:run scope authorizes supported execution operations, not every read. See the authentication model before choosing a credential.
Add scopes or bind the token to an account when you need tighter isolation:
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:runList and revoke keys:
chainabit auth keys list
chainabit auth keys revoke "$ID"API: Password Login
See Prerequisites for authentication and shared environment setup.
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"
}'Store data.tokens.accessToken and data.tokens.refreshToken only after successful admission. A server response of 403 MFA_LOGIN_REQUIRED or 403 MFA_RECOVERY_REQUIRED contains no session pair: continue in Chainabit's verification or exceptional recovery flow. Do not save its continuation as an API credential.
If password login through the CLI returns one of these codes, it reports chainabit auth login --device as the next command and saves no credentials. That guidance applies to those sign-in refusals, not every 403.
API: Mailbox Sign-In with Explicit Consent
Opening an email confirmation or magic link must stage sign-in, not silently replace the receiving app's account. Before verifying the email proof, generate a random private 43-character base64url codeVerifier. Derive the 43-character appCodeChallenge as BASE64URL(SHA-256(codeVerifier)). Keep the verifier private to that receiving app; do not put it in the email link, a callback URL, or logs.
Send these fields to POST /auth/confirm-email for confirmation, or POST /auth/magic-link/verify for a magic link:
{
"email": "you@example.com",
"token": "YOUR_EMAIL_PROOF_TOKEN",
"appCodeChallenge": "YOUR_BASE64URL_SHA256_CHALLENGE"
}The response's data contains:
{
"status": "sign_in_confirmation_required",
"challengeId": "<returned-challenge-id>",
"completionToken": "<returned-completion-token>",
"expiresAt": "<ISO-8601-expiry>",
"email": "you@example.com"
}There are no session tokens at this stage. Display the API-returned email and offer one explicit sign-in action plus cancel. Do not trust the email in the delivered URL as the display identity. The confirmation has a five-minute deadline.
Only after the user chooses to sign in as that identity, send:
curl -X POST "https://api.chainabit.com/api/v1/auth/mailbox-login/complete" \
-H "Content-Type: application/json" \
-d '{
"challengeId": "<returned-challenge-id>",
"completionToken": "<returned-completion-token>",
"codeVerifier": "<original-private-code-verifier>"
}'An authenticated result has data.status: "authenticated" and data.session.tokens. A result with status: "mfa_required" or status: "recovery_required" instead provides the server's challenge; complete that flow before adopting a session. A wrong verifier or a capability from a different confirmation is refused. Successful completion is one-use.
If the first mailbox claim retired an unproven registration password, the eventual session includes passwordSetupRequired: true. Use emailed password recovery to choose a new password; do not treat this presentation flag as permission to change credentials.
API: Password Recovery
Request a password-reset email through the captcha-protected POST /auth/forgot-password. The emailed reset code is distinct from a saved MFA recovery code. Exchange it for a restricted grant:
curl -X POST "https://api.chainabit.com/api/v1/auth/exchange-recovery-code" \
-H "Content-Type: application/json" \
-d '{"code":"YOUR_PASSWORD_RESET_CODE"}'data.accessToken is a five-minute, one-use password-reset grant. It does not sign the account in and cannot be used as an ordinary API bearer credential. Use it in the reset request body:
curl -X POST "https://api.chainabit.com/api/v1/auth/reset-password" \
-H "Content-Type: application/json" \
-d '{
"accessToken": "YOUR_PASSWORD_RESET_GRANT",
"newPassword": "yourNewPassword123"
}'Success returns data.status: "ok", revokes the former session, and requires a new sign-in. Replayed or expired grants return INVALID_CHALLENGE and cannot change the password.
API: Send Authenticated Requests
curl "https://api.chainabit.com/api/v1/ai/sessions" \
-H "Authorization: Bearer $TOKEN"For a refreshable human session, replace both tokens after a successful refresh and retry once. A revoked or expired developer credential remains denied; it cannot be renewed by completing a human-verification challenge.
API: Refresh Session
curl -X POST "https://api.chainabit.com/api/v1/auth/refresh" \
-H "Content-Type: application/json" \
-d '{"refreshToken":"'"$REFRESH_TOKEN"'"}'Replace both stored tokens after a successful refresh. Refresh tokens are single-use.
API: Developer-Token Authority
Current servers accept cbt_live_... developer tokens directly as scoped bearer credentials. Any compatibility exchange preserves non-interactive authority; it does not provide proof of human verification or permission to manage credentials. A revoked or expired developer token must be replaced rather than treated as a sign-in challenge.
Captcha-Protected Flows
When CAPTCHA protection is enabled, registration, login, password recovery, and confirmation resend require a Turnstile token in the x-turnstile-token header or captchaToken request field. Developer-token exchange is a separate endpoint and does not use this guard.