Auth API
User registration, authentication, session management, and account security.
Base Path
/authAuthentication
Authentication requirements vary by endpoint. Some require JWT Bearer tokens, some require captcha verification, and some require no authentication at all. See the table below for specifics.
Chainabit also exposes a separate OAuth 2.0 provider surface for partner applications. That provider flow is documented in OAuth 2.0 Provider Guide.
Set up authentication and the shared environment in Prerequisites.
Example identifiers
export REFRESH_TOKEN="your-refresh-token"Endpoints
| Method | Path | Description | Auth |
|---|---|---|---|
| POST | /auth/register | Register a new account | Captcha |
| POST | /auth/login | Password verification and server-controlled sign-in admission | Captcha |
| POST | /auth/logout | Invalidate the current session | JWT |
| POST | /auth/refresh | Refresh access and refresh tokens | None |
| POST | /auth/confirm-email | Confirm email and stage explicit sign-in consent | None |
| POST | /auth/mailbox-login/complete | Complete consent with the original receiving-app verifier | None |
| POST | /auth/resend-confirmation | Resend email confirmation | Captcha |
| POST | /auth/forgot-password | Request password reset email | Captcha |
| POST | /auth/exchange-recovery-code | Exchange recovery code for reset token | None |
| POST | /auth/reset-password | Set a new password using reset token | None |
| GET | /auth/check-username | Check username availability | JWT |
| POST | /auth/claim-username | Claim a username | JWT |
| POST | /auth/change-email | Change account email | JWT |
| POST | /auth/change-password | Change account password | JWT |
| PATCH | /auth/profile | Update user profile | JWT |
| GET | /auth/session | Get current session details | JWT |
| POST | /auth/magic-link | Send magic link email | Captcha |
| POST | /auth/magic-link/verify | Verify magic link and stage explicit sign-in consent | None |
| GET | /auth/oauth/providers | List OAuth providers | None |
| GET | /auth/oauth/:provider | Get OAuth authorization URL | None |
| GET | /auth/oauth/:provider/callback | Handle OAuth callback | None |
| POST | /auth/oauth/:provider/link | Link OAuth provider | JWT |
| DELETE | /auth/oauth/:provider/unlink | Unlink OAuth provider | JWT |
| GET | /auth/oauth/linked | List linked providers | JWT |
| POST | /oauth/token | Exchange an authorization code or refresh token | Client auth |
| POST | /oauth/revoke | Revoke an OAuth access or refresh token | Client auth |
| GET | /oauth/userinfo | Resolve the authenticated OAuth subject | OAuth bearer |
| POST | /auth/device/authorize | Generate device codes | None |
| POST | /auth/device/approve | Approve a CLI device code from an authenticated browser session | JWT |
| POST | /auth/device/token | Poll device authorization | None |
| GET | /auth/developer-tokens/catalog | Read the permissions and expiry presets a developer token can use | JWT |
| POST | /auth/developer-tokens | Create a time-bounded developer token | JWT |
| GET | /auth/developer-tokens | List developer tokens for the current user | JWT |
| DELETE | /auth/developer-tokens/:id | Revoke a developer token | JWT |
| POST | /auth/developer-tokens/exchange | Exchange a developer token for a session payload | None |
POST /auth/register
Register a new user account and send a confirmation email.
Authentication: None (Captcha required) Rate limit: Rate-limited; honour 429 and Retry-After
Note: This endpoint requires captcha verification. Include a valid captcha token in the
x-turnstile-tokenheader.
Request
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
email | string | Yes | Valid email format | Account email address |
password | string | Yes | 8-128 characters | Account password |
fullName | string | No | Max 120 characters | User's full name |
referralAttributionToken | string | No | UUID | Attribution token captured from POST /api/v1/referrals/click |
referralInviteCode | string | No | Max 32 characters | Invite code forwarded during referral-aware signup |
Note:
referralAttributionTokenis optional. Use the value returned byPOST /api/v1/referrals/click, not the placeholder shown below.
Response
Response Example
{
"data": {
"userId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"email": "alice@example.com",
"requiresEmailVerification": true
}
}Response Fields
| Field | Type | Description |
|---|---|---|
userId | string | Unique identifier for the newly created user |
email | string | Email address of the registered account |
requiresEmailVerification | boolean | Whether the account must confirm its email before logging in |
Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/register \
-H "Content-Type: application/json" \
-H "x-turnstile-token: <captcha-token>" \
-d '{
"email": "alice@example.com",
"password": "secureP@ss123",
"fullName": "Alice Johnson",
"referralAttributionToken": "<referral-attribution-token>",
"referralInviteCode": "ABC123"
}'POST /auth/login
Verify the password and evaluate the account's current sign-in requirements. Access and refresh tokens are returned only after admission succeeds.
Authentication: None (Captcha required) Rate limit: Rate-limited; honour 429 and Retry-After
Note: This endpoint is intended for browser and first-party web UI flows. CLI and automation clients should prefer the device flow or developer-token exchange endpoints below. This endpoint also requires captcha verification. Include a valid captcha token in the
x-turnstile-tokenheader.
Request
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
identifier | string | Yes | Max 256 characters | Email address or username |
password | string | Yes | Max 128 characters | Account password |
rememberMe | boolean | No | -- | Extend token expiry for longer sessions |
Response
Response Example
This example shows successful admission. 403 MFA_LOGIN_REQUIRED or 403 MFA_RECOVERY_REQUIRED instead requires the server-provided verification or exceptional recovery continuation and does not issue session tokens. Do not store continuation tokens as bearer credentials or infer that password verification bypasses MFA.
{
"data": {
"userId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"email": "alice@example.com",
"profileReady": false,
"requiresEmailVerification": false,
"provider": "email",
"rememberMe": false,
"accountStatus": { "deletion": null, "ban": null },
"authority": { "scope": "person" },
"preferences": { "aiPersona": "motivational", "aiMessageSuggestionCount": 2, "bitView": "matrix", "chainView": "puzzle", "countryCode": null, "quietHours": null },
"tokens": {
"accessToken": "YOUR_ACCESS_TOKEN",
"refreshToken": "YOUR_REFRESH_TOKEN",
"expiresIn": 900,
"tokenType": "bearer",
"expiresAt": 1788634555
},
"subscription": {
"planCode": "FREE",
"planName": "Free",
"variantId": "<plan-variant-id>",
"status": "free",
"provider": null
},
"profile": {
"username": null,
"fullName": "Alice Johnson",
"avatarUrl": null,
"isReady": false
},
"defaultAccount": { "id": "00000000-0000-4000-8000-000000000002", "name": "Personal", "slug": "default" },
"workspaces": [{ "id": "00000000-0000-4000-8000-000000000003", "accountId": "00000000-0000-4000-8000-000000000002", "name": "Default Workspace", "accountName": "Personal", "slug": "default", "isDefault": true, "productMode": "personal" }]
}
}Treat userId, email, and tokens as the stable contract. Everything else is account context the client uses to render itself, but it isn't versioned for external integrations and may change shape without notice.
Response Fields
| Field | Type | Description |
|---|---|---|
userId | string | Unique identifier for the authenticated user |
email | string | Email address of the account |
profileReady | boolean | Whether the user has completed profile setup |
requiresEmailVerification | boolean | Whether the account still needs to confirm its email |
rememberMe | boolean | Whether the extended session was requested |
accountStatus.deletion | object | null | A pending deletion of the account, or null |
accountStatus.ban | object | null | An active restriction on the account, or null |
authority.scope | string | Who the session acts for; person for a person's own sign-in |
preferences | object | The person's saved preferences, the same object as in GET /auth/session; trimmed in the example above |
tokens.accessToken | string | JWT access token for authenticating requests |
tokens.refreshToken | string | Token used to obtain a new access token |
tokens.expiresIn | number | Access token lifetime in seconds (900 by default) |
tokens.tokenType | string | Token scheme (bearer) |
tokens.expiresAt | number | Unix timestamp (seconds) when the access token expires |
subscription.planCode | string | Active subscription plan code |
subscription.status | string | Subscription status |
profile.username | string | null | Username, if claimed |
Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/login \
-H "Content-Type: application/json" \
-H "x-turnstile-token: <captcha-token>" \
-d '{
"identifier": "alice@example.com",
"password": "secureP@ss123",
"rememberMe": true
}'POST /auth/logout
Invalidate the current session and revoke tokens.
Authentication: JWT required
Request
No path, query, or body parameters. Requires Authorization: Bearer $TOKEN.
Response
Response Example
{
"data": { "status": "ok" }
}The current session is invalidated server-side — reusing the same access token afterward returns 401 Unauthorized (Session not found), even though the JWT itself hasn't expired yet.
Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/logout \
-H "Authorization: Bearer $TOKEN"POST /auth/refresh
Exchange a refresh token for a new pair of access and refresh tokens.
Authentication: None
Important: Refresh tokens are rotated on every successful refresh. Clients must replace any stored refresh token with the new
tokens.refreshTokenreturned by this endpoint. Reusing an older refresh token will return401 Unauthorized.
Request
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
refreshToken | string | Yes | -- | Refresh token from a previous login or refresh |
Response
Response Example
{
"data": {
"userId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"email": "alice@example.com",
"tokens": {
"accessToken": "YOUR_ACCESS_TOKEN",
"refreshToken": "YOUR_REFRESH_TOKEN",
"expiresIn": 900,
"tokenType": "bearer",
"expiresAt": 1788634652
}
}
}The response carries the same shape as POST /auth/login — tokens plus the same account context (subscription, profile, workspaces, etc.), refreshed with any changes since the last token was issued. Only tokens (and userId/email) are the stable contract; see the login response above for the full field notes.
Response Fields
| Field | Type | Description |
|---|---|---|
tokens.accessToken | string | New JWT access token |
tokens.refreshToken | string | New refresh token (rotated on each refresh) |
tokens.expiresIn | number | Access token lifetime in seconds (900 by default) |
tokens.tokenType | string | Token scheme (bearer) |
tokens.expiresAt | number | Unix timestamp (seconds) when the new access token expires |
Client Warning
- Always persist the latest
tokens.refreshTokenfrom the response. - Never assume the previous refresh token remains valid after a successful refresh.
- If refresh fails with
Invalid refresh token, verify the client is not replaying an older token.
Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/refresh \
-H "Content-Type: application/json" \
-d '{
"refreshToken": "YOUR_REFRESH_TOKEN"
}'POST /auth/confirm-email
Confirm a user's email address using the emailed proof and stage explicit identity consent in the receiving app. This step does not issue a session.
Authentication: None Rate limit: Rate-limited; honour 429 and Retry-After
Request
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
email | string | Yes | Valid email | The account email being confirmed |
token | string | Yes | Max 128 chars | Either the token from the confirmation link, or the shorter printed code |
appCodeChallenge | string | Yes | 43 base64url characters | S256 hash of the receiving app's private codeVerifier |
Response
{
"data": {
"status": "sign_in_confirmation_required",
"challengeId": "<returned-challenge-id>",
"completionToken": "<returned-completion-token>",
"expiresAt": "<ISO-8601-expiry>",
"email": "alice@example.com"
}
}Generate a random private 43-character base64url verifier before the request and derive appCodeChallenge = BASE64URL(SHA-256(codeVerifier)). The verifier must stay with the receiving app, outside callback URLs and logs.
Display the API-returned identity and ask the user to explicitly sign in as that email. Use POST /auth/mailbox-login/complete only after that choice. This five-minute confirmation contains no access or refresh tokens.
Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/confirm-email \
-H "Content-Type: application/json" \
-d '{
"email": "alice@example.com",
"token": "YOUR_EMAIL_CONFIRMATION_TOKEN",
"appCodeChallenge": "YOUR_BASE64URL_SHA256_CHALLENGE"
}'POST /auth/mailbox-login/complete
Complete the receiving app's explicit sign-in choice for an identity staged by email confirmation or a magic link. Do not call this endpoint automatically when a link opens.
Authentication: The returned confirmation capability and original private verifier Rate limit: Rate-limited; honour 429 and Retry-After
Request
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
challengeId | string | Yes | UUID | ID returned when the email proof was verified |
completionToken | string | Yes | 43 base64url characters | Capability returned for that exact confirmation |
codeVerifier | string | Yes | 43 base64url characters | Original private verifier whose S256 challenge was submitted |
Response
data.status | Result |
|---|---|
authenticated | data.session contains the admitted session and its tokens |
mfa_required | data.challenge contains the server-required sign-in verification continuation |
recovery_required | data.challenge contains the exceptional recovery admission continuation |
A missing, wrong, or foreign verifier cannot complete the confirmation. Successful completion is one-use. Verification and recovery continuations do not authorize ordinary API requests.
When the first mailbox claim retired a password supplied before ownership was proven, the final session includes passwordSetupRequired: true. This is a presentation fact: use emailed password recovery to choose a password, not an unauthenticated password setter.
Code Example
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>"
}'POST /auth/resend-confirmation
Resend the email confirmation link to a registered address.
Authentication: None (Captcha required) Rate limit: Rate-limited; honour 429 and Retry-After
Note: This endpoint requires captcha verification. Include a valid captcha token in the
x-turnstile-tokenheader.
Request
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
email | string | Yes | Valid email format | Email address to resend confirmation to |
Response
Response Example
{
"data": {
"message": "Confirmation email sent."
},
"meta": null,
"error": null
}Response Fields
| Field | Type | Description |
|---|---|---|
message | string | Human-readable status message |
Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/resend-confirmation \
-H "Content-Type: application/json" \
-H "x-turnstile-token: <captcha-token>" \
-d '{
"email": "alice@example.com"
}'POST /auth/forgot-password
Send a password reset email to the specified address.
Authentication: None (Captcha required) Rate limit: Rate-limited; honour 429 and Retry-After
Note: This endpoint requires captcha verification. Include a valid captcha token in the
x-turnstile-tokenheader.
Request
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
email | string | Yes | Valid email format | Account email address |
redirectTo | string | No | Valid URL, max 300 characters | URL opened by the link in the password reset email |
Response
Response Example
{
"data": {
"status": "ok"
}
}Response Fields
| Field | Type | Description |
|---|---|---|
status | string | Request status (ok) |
Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/forgot-password \
-H "Content-Type: application/json" \
-H "x-turnstile-token: <captcha-token>" \
-d '{
"email": "alice@example.com",
"redirectTo": "https://chainabit.com/auth/reset-password"
}'POST /auth/exchange-recovery-code
Exchange the code from the password-reset email for a restricted, five-minute password-reset grant. This code is distinct from a saved MFA recovery code. The exchange creates no ordinary session.
Authentication: None Rate limit: Rate-limited; honour 429 and Retry-After
Request
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
code | string | Yes | -- | Recovery code from the password reset email |
Response
Response Example
{
"data": {
"accessToken": "YOUR_PASSWORD_RESET_GRANT"
}
}Response Fields
| Field | Type | Description |
|---|---|---|
accessToken | string | One-use password-reset grant, valid for five minutes; cannot authenticate ordinary API requests |
Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/exchange-recovery-code \
-H "Content-Type: application/json" \
-d '{
"code": "YOUR_PASSWORD_RESET_CODE"
}'POST /auth/reset-password
Set a new password using the restricted grant from the emailed password-reset code exchange. Send the grant in the request body, not as an ordinary bearer credential.
Authentication: None Rate limit: Rate-limited; honour 429 and Retry-After
Request
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
accessToken | string | Yes | Unexpired, unused grant | Grant obtained from the emailed password-reset code exchange |
newPassword | string | Yes | 8-128 characters | New account password |
Response
Response Example
{
"data": {
"status": "ok"
}
}Response Fields
| Field | Type | Description |
|---|---|---|
status | string | ok after successful password replacement |
Success revokes the former session and does not sign the account in. Sign in again with the chosen password and complete the server's current requirements. An expired or reused grant returns INVALID_CHALLENGE without changing the password.
Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/reset-password \
-H "Content-Type: application/json" \
-d '{
"accessToken": "YOUR_PASSWORD_RESET_GRANT",
"newPassword": "newSecureP@ss456"
}'GET /auth/check-username
Check whether a username is available for claiming.
Authentication: JWT required Rate limit: Rate-limited; honour 429 and Retry-After
Request
| Parameter | Type | Required | Constraints | Description |
|---|---|---|---|---|
username | string | Yes | 3-24 characters, alphanumeric and underscores only | Username to check availability for |
Response
Response Example
{
"data": {
"username": "alice_j",
"available": true
},
"meta": null,
"error": null
}Response Fields
| Field | Type | Description |
|---|---|---|
username | string | The username that was checked |
available | boolean | Whether the username is available for claiming |
Code Examples
curl "https://api.chainabit.com/api/v1/auth/check-username?username=alice_j" \
-H "Authorization: Bearer $TOKEN"POST /auth/claim-username
Claim a username for the authenticated account.
Authentication: JWT required Rate limit: Rate-limited; honour 429 and Retry-After
Note: This endpoint uses
application/x-www-form-urlencodedcontent type, not JSON. Send the username as a form field.
Request
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
username | string | Yes | 3-24 characters, alphanumeric and underscores only | Username to claim |
Response
Response Example
{
"data": {
"username": "alice_j",
"claimedAt": "2026-03-17T12:00:00.000Z"
},
"meta": null,
"error": null
}Response Fields
| Field | Type | Description |
|---|---|---|
username | string | The username that was claimed |
claimedAt | string | ISO 8601 timestamp when the username was claimed |
Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/claim-username \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=alice_j"POST /auth/change-email
Request an email address change. A confirmation link is sent to the new address after recent re-authentication.
Authentication: JWT required Rate limit: Rate-limited; honour 429 and Retry-After
The first valid request without a recent step-up proof returns 403 STEP_UP_REQUIRED. Read error.details.challenge, complete its server-directed verification sequence, then retry the same request. A password proof for this action must be bound to the new email address. The proof is single-use.
Request
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
email | string | Yes | Valid email format | New email address |
Response
Response Example
{
"data": {
"status": "pending_verification",
"email": "alice.new@example.com"
}
}Response Fields
| Field | Type | Description |
|---|---|---|
status | string | pending_verification until the new address is confirmed |
email | string | Normalized new email address |
Use the returned challenge as the authority for the verification sequence. Do not hardcode an assurance level or a fixed list of methods; the current account and operation determine what the server offers.
Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/change-email \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"email": "alice.new@example.com"
}'POST /auth/change-password
Change the authenticated user's password after recent re-authentication.
Authentication: JWT required Rate limit: Rate-limited; honour 429 and Retry-After
The first valid request without a recent step-up proof returns 403 STEP_UP_REQUIRED with error.details.challenge. Complete one of the offered methods and retry the same request. A password proof for this action must be bound to the user's ID. The proof is single-use; a successful change revokes existing sessions.
Request
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
oldPassword | string | Yes | 8-128 characters | Current account password |
newPassword | string | Yes | 8-128 characters | New account password |
Response
Response Example
{
"data": {
"status": "ok"
}
}Response Fields
| Field | Type | Description |
|---|---|---|
status | string | ok after the password is changed |
Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/change-password \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"oldPassword": "secureP@ss123",
"newPassword": "newSecureP@ss456"
}'PATCH /auth/profile
Update the authenticated user's profile information.
Authentication: JWT required Rate limit: Rate-limited; honour 429 and Retry-After
Request
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
fullName | string | No | Max 50 characters | Display name |
avatarUrl | string | No | Valid URL | Profile avatar URL |
bio | string | No | Max 160 characters | Profile biography |
tagline | string | No | Max 60 characters | Short tagline |
visibility | string | No | public or private | Profile visibility setting |
Response
Response Example
{
"data": {
"username": "alice_j",
"fullName": "Alice J.",
"avatarUrl": "https://cdn.chainabit.com/avatars/alice.jpg",
"bio": "Productivity enthusiast and AI builder.",
"tagline": "Chainer since 2025",
"visibility": "public"
},
"meta": null,
"error": null
}Response Fields
| Field | Type | Description |
|---|---|---|
username | string | The user's claimed username |
fullName | string | Updated display name |
avatarUrl | string | URL of the profile avatar |
bio | string | Updated profile biography |
tagline | string | Updated short tagline |
visibility | string | Updated profile visibility (public or private) |
Code Examples
curl -X PATCH https://api.chainabit.com/api/v1/auth/profile \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"fullName": "Alice J.",
"bio": "Productivity enthusiast and AI builder.",
"visibility": "public"
}'GET /auth/session
Retrieve the full session context for the currently authenticated user.
Authentication: JWT required
Request
No path, query, or body parameters. Requires Authorization: Bearer $TOKEN.
Response
Response Example
{
"data": {
"user": {
"id": "00000000-0000-4000-8000-000000000007",
"email": "alice@example.com"
},
"profile": {
"username": null,
"fullName": "Alice Johnson",
"avatarUrl": null,
"bio": null,
"tagline": null,
"visibility": "private",
"isReady": false,
"onboarding": {
"status": "not_started",
"currentStep": 0
},
"badge": {
"rank": 8,
"tier": "platinum",
"awardedAt": "2026-10-25T09:00:00.000Z"
}
},
"preferences": {
"email": true,
"push": true,
"friendActivity": true,
"aiReminders": true,
"countryCode": null,
"languageCode": null,
"discoverableByEmail": true,
"aiTraining": true,
"aiMemory": true,
"aiMessageSuggestionsEnabled": true,
"aiMessageSuggestionCount": 2,
"aiCustomInstructionsEnabled": false,
"aiCustomInstructions": null,
"aiPersona": "motivational",
"chainView": "puzzle",
"bitView": "matrix",
"bitViews": [
{
"id": "list",
"enabled": true
},
{
"id": "calendar",
"enabled": true
},
{
"id": "kanban",
"enabled": true
},
{
"id": "matrix",
"enabled": true
},
{
"id": "gantt",
"enabled": true
},
{
"id": "singularity",
"enabled": false
},
{
"id": "tree",
"enabled": false
},
{
"id": "zen",
"enabled": false
}
],
"keyboardShortcuts": true,
"digest": "daily",
"notificationFrequencyMode": "balanced",
"quietHours": null,
"timezone": null,
"useLatestSessions": true
},
"subscription": {
"planCode": "FREE",
"planName": "Free",
"variantId": "<plan-variant-id>",
"status": "free",
"provider": null
},
"defaultAccount": {
"id": "00000000-0000-4000-8000-000000000002",
"name": "Personal",
"slug": "default"
},
"workspaces": [
{
"id": "00000000-0000-4000-8000-000000000001",
"accountId": "00000000-0000-4000-8000-000000000002",
"name": "Default Workspace",
"slug": "default",
"isDefault": true,
"productMode": "personal",
"accountName": "Personal"
},
{
"id": "00000000-0000-4000-8000-000000000003",
"accountId": "00000000-0000-4000-8000-000000000004",
"name": "Default Workspace",
"slug": "default",
"isDefault": true,
"productMode": "business",
"businessLifecycle": "active",
"accountName": "Acme"
},
{
"id": "00000000-0000-4000-8000-000000000005",
"accountId": "00000000-0000-4000-8000-000000000006",
"name": "Default Workspace",
"slug": "default",
"isDefault": true,
"productMode": "business",
"businessLifecycle": "active",
"accountName": "Globex"
}
],
"identity": {
"hasPassword": true,
"linkedProviders": []
},
"authority": {
"scope": "person"
}
}
}Treat user.id, user.email and workspaces[] as the stable contract. The example above uses placeholder identifiers, names and address. The person here belongs to two organizations whose default workspaces are both called "Default Workspace", so accountName is what tells them apart. The response carries data only; there is no meta or error member.
Response Fields
| Field | Type | Description |
|---|---|---|
user.id | string (uuid) | Unique identifier for the user |
user.email | string | Email address of the account |
profile.username | string | null | Claimed username |
profile.fullName | string | null | Display name |
profile.avatarUrl | string | null | URL of the profile avatar |
profile.bio | string | null | Profile biography |
profile.tagline | string | null | Short tagline |
profile.visibility | string | null | Profile visibility (public or private) |
profile.isReady | boolean | Whether the profile setup is complete |
profile.onboarding | object | null | Onboarding progress: status (string) and currentStep (number) |
profile.badge | object | null | Chainer badge: rank (number), tier (string or null) and awardedAt (ISO 8601 timestamp) |
preferences | object | The user's saved preferences (notifications, language, timezone, AI behaviour and view settings); the fields are shown in the example |
subscription.planCode | string | Active subscription plan code |
subscription.planName | string | Display name of the plan |
subscription.variantId | string (uuid) | Identifier of the active plan variant |
subscription.status | string | Subscription status |
subscription.provider | string | null | Payment provider of the active subscription, or null |
defaultAccount.id | string (uuid) | Identifier of the person's own account |
defaultAccount.name | string | Name of the default account, by the same rule as workspaces[].accountName |
defaultAccount.slug | string | null | Slug of the default account's default workspace |
workspaces[].id | string (uuid) | Unique identifier for a workspace |
workspaces[].accountId | string (uuid) | Owning account. Send it as x-account-id to act in that account |
workspaces[].name | string | Name of the workspace itself. Default workspaces of different organizations can share a name |
workspaces[].accountName | string | null | Name of the owning account: the organization name for a business workspace, Personal as the fallback for a personal account. Use it, not name, to tell organizations apart. It is the same name the OAuth consent page offers for that account |
workspaces[].slug | string | URL slug of the workspace |
workspaces[].isDefault | boolean | Whether it is the default workspace of its account |
workspaces[].productMode | string | personal, business or unavailable |
workspaces[].businessLifecycle | string | Present for business workspaces: active, restricted, onboarding_required or legacy_review |
identity.hasPassword | boolean | Whether the account has a password |
identity.linkedProviders[] | string[] | Sign-in providers linked to the account |
authority.scope | string | person (any account the person may enter) or organization (a session confined to one organization, which adds accountId, slug and expiresAt) |
Code Examples
curl "https://api.chainabit.com/api/v1/auth/session" \
-H "Authorization: Bearer $TOKEN"POST /auth/magic-link
Send a magic link to the specified email address for passwordless sign-in.
Authentication: None (Captcha required) Rate limit: Rate-limited; honour 429 and Retry-After
Request
| Field | Type | Required | Description |
|---|---|---|---|
email | string | Yes | Email address to send the magic link to |
redirectTo | string | No | URL to redirect after verification |
Response
Response Example
{
"data": {
"status": "ok"
},
"meta": null,
"error": null
}Note: This endpoint always returns
{ "status": "ok" }regardless of whether the email exists to prevent account enumeration.
Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/magic-link \
-H "Content-Type: application/json" \
-H "x-turnstile-token: <captcha-token>" \
-d '{
"email": "alice@example.com"
}'POST /auth/magic-link/verify
Verify the emailed magic-link proof and stage explicit identity consent in the receiving app. This step does not create a session.
Authentication: None Rate limit: Rate-limited; honour 429 and Retry-After
Request
| Field | Type | Required | Description |
|---|---|---|---|
token | string | Yes | Magic link token from the email |
email | string | Yes | Email address used when sending |
appCodeChallenge | string | Yes | 43-character base64url S256 hash of the receiving app's private verifier |
Response
Returns the same sign_in_confirmation_required descriptor as POST /auth/confirm-email: API-verified email, challengeId, completionToken, and expiresAt, with no session tokens. Display that identity and complete POST /auth/mailbox-login/complete only after the user's explicit sign-in choice. Replaying the emailed proof returns INVALID_CHALLENGE.
Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/magic-link/verify \
-H "Content-Type: application/json" \
-d '{
"token": "YOUR_MAGIC_LINK_TOKEN",
"email": "alice@example.com",
"appCodeChallenge": "YOUR_BASE64URL_SHA256_CHALLENGE"
}'GET /auth/oauth/providers
List available OAuth providers.
Authentication: None Rate limit: Rate-limited; honour 429 and Retry-After
Request
No path, query, or body parameters.
Response
Response Example
{
"data": {
"providers": ["google", "github", "microsoft"]
},
"meta": null,
"error": null
}Code Examples
curl "https://api.chainabit.com/api/v1/auth/oauth/providers"GET /auth/oauth/:provider
Starts a configured social-provider sign-in ceremony. Use the provider controls in Chainabit's sign-in interface so the initiating app owns the continuation. A provider's availability does not bypass the account's sign-in requirements.
This social sign-in surface is separate from partner OAuth authorization.
GET /auth/oauth/:provider/callback
The provider invokes this callback as part of the original sign-in ceremony. It is not a manual sign-in endpoint. Do not adopt access or refresh tokens from an arbitrary delivered URL; receiving a callback does not itself establish the app's authority to sign in.
POST /auth/oauth/:provider/link
Link an OAuth provider to an existing authenticated account.
Authentication: JWT required Rate limit: Rate-limited; honour 429 and Retry-After
Request
| Parameter | Type | Description |
|---|---|---|
redirectTo | string | Optional redirect URL after linking |
Response
Response Example
{
"data": { "url": "https://github.com/login/oauth/authorize?..." },
"meta": null,
"error": null
}Code Example
curl -X POST "https://api.chainabit.com/api/v1/auth/oauth/github/link" \
-H "Authorization: Bearer $TOKEN"DELETE /auth/oauth/:provider/unlink
Remove a linked OAuth provider from the account.
Authentication: JWT required Rate limit: Rate-limited; honour 429 and Retry-After
Safety: Cannot unlink the last authentication method. If the provider is the only identity and the account has no password set, this returns
400 Bad Request.
Request
No path, query, or body parameters. Requires Authorization: Bearer $TOKEN.
Response
Response Example
{
"data": { "message": "Provider unlinked successfully" },
"meta": null,
"error": null
}Code Example
curl -X DELETE "https://api.chainabit.com/api/v1/auth/oauth/github/unlink" \
-H "Authorization: Bearer $TOKEN"GET /auth/oauth/linked
List all OAuth providers linked to the authenticated account.
Authentication: JWT required Rate limit: Rate-limited; honour 429 and Retry-After
Request
No path, query, or body parameters. Requires Authorization: Bearer $TOKEN.
Response
Response Example
{
"data": [
{
"provider": "google",
"providerId": "1234567890",
"email": "alice@gmail.com",
"linkedAt": "2026-03-18T10:00:00.000Z"
}
],
"meta": null,
"error": null
}Code Example
curl "https://api.chainabit.com/api/v1/auth/oauth/linked" \
-H "Authorization: Bearer $TOKEN"POST /auth/device/authorize
Generate device and user codes for CLI authentication.
Authentication: None Rate limit: Rate-limited; honour 429 and Retry-After
Request
The request body fields are optional, but CLI clients should send descriptive metadata when available:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | No | Device display name such as chainabit-cli |
deviceType | string | No | Client type such as cli |
appVersion | string | No | Client version for audit and support diagnostics |
settings | object | No | Free-form client metadata |
Response
Response Example
{
"data": {
"deviceCode": "YOUR_DEVICE_CODE",
"userCode": "ABCD-1234",
"verificationUri": "https://chainabit.com/auth/device",
"verificationUriComplete": "https://chainabit.com/auth/device?code=ABCD-1234",
"expiresIn": 300,
"interval": 5
},
"meta": null,
"error": null
}Open verificationUriComplete directly in the browser — it includes the code pre-filled so the user does not have to type it manually.
Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/device/authorizePOST /auth/device/approve
Approve a pending device code from an already authenticated browser session.
Authentication: JWT required Rate limit: Rate-limited; honour 429 and Retry-After
Request
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
userCode | string | Yes | XXXX-XXXX | User-facing device code shown by the CLI |
Response
Response Example
{
"data": {
"approved": true,
"userCode": "ABCD-EFGH"
},
"meta": null,
"error": null
}The authenticated browser session remains in control of approval. The CLI never receives the browser token directly; it keeps polling POST /auth/device/token until approval is complete.
Code Example
curl -X POST https://api.chainabit.com/api/v1/auth/device/approve \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"userCode": "ABCD-EFGH"
}'POST /auth/device/token
Poll for device authorization result. Call this endpoint at the interval rate until the status changes.
Authentication: None Rate limit: Rate-limited; honour 429 and Retry-After
Request
| Field | Type | Required | Description |
|---|---|---|---|
deviceCode | string | Yes | Device code from the authorize response |
Response
Response Examples
Pending:
{ "data": { "status": "authorization_pending" } }Expired:
{ "data": { "status": "expired" } }Approved (schematic):
{
"data": {
"status": "approved",
"session": { ... }
}
}Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/device/token \
-H "Content-Type: application/json" \
-d '{ "deviceCode": "YOUR_DEVICE_CODE" }'POST /auth/developer-tokens
Create a time-bounded developer token for CLI or automation sign-in. The opaque token value is returned only once.
The request also accepts scopes, expiry presets, allowedNetworks, catalogVersion and accountId. See Developer access for every field, the permission catalog, network restrictions and the error codes.
Authentication: JWT required Rate limit: Rate-limited; honour 429 and Retry-After
Request
| Field | Type | Required | Constraints | Description |
|---|---|---|---|---|
label | string | Yes | max 80 characters | Friendly name such as GitHub Actions |
expiresInDays | number | No | 1-365, default 30 | Lifetime of the developer token |
Response
Response Example
{
"data": {
"id": "00000000-0000-4000-8000-00000000d001",
"label": "GitHub Actions",
"token": "YOUR_DEVELOPER_TOKEN",
"tokenPreview": "YOUR_TOKEN_PREVIEW",
"expiresAt": "2026-04-27T10:00:00.000Z",
"createdAt": "2026-03-28T10:00:00.000Z"
},
"meta": null,
"error": null
}Code Examples
curl -X POST https://api.chainabit.com/api/v1/auth/developer-tokens \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{ "label": "GitHub Actions", "expiresInDays": 30 }'GET /auth/developer-tokens
List developer tokens owned by the current user. The raw token is never returned again; only a safe preview and metadata are exposed.
Authentication: JWT required Rate limit: Rate-limited; honour 429 and Retry-After
Request
No path, query, or body parameters. Requires Authorization: Bearer $TOKEN.
Response
{
"data": [
{
"id": "00000000-0000-4000-8000-00000000d001",
"label": "GitHub Actions",
"tokenPreview": "YOUR_TOKEN_PREVIEW",
"expiresAt": "2026-04-27T10:00:00.000Z",
"createdAt": "2026-03-28T10:00:00.000Z"
}
],
"meta": null,
"error": null
}Code Examples
curl https://api.chainabit.com/api/v1/auth/developer-tokens \
-H "Authorization: Bearer $TOKEN"DELETE /auth/developer-tokens/:id
Revoke a developer token.
Authentication: JWT required Rate limit: Rate-limited; honour 429 and Retry-After
Request
Path params: id — from a POST /auth/developer-tokens or GET /auth/developer-tokens response's data.id / data[].id, exposed as $DEVELOPER_TOKEN_ID below.
Response
{
"data": { "revoked": true },
"meta": null,
"error": null
}Code Examples
curl -X DELETE https://api.chainabit.com/api/v1/auth/developer-tokens/$DEVELOPER_TOKEN_ID \
-H "Authorization: Bearer $TOKEN"POST /auth/developer-tokens/exchange
Compatibility exchange for supported developer credentials. Exchanged authority remains non-interactive: it cannot satisfy human verification or authorize developer-token administration.
Current automation should use the original scoped developer token directly as a bearer credential. An exchange must not be treated as an upgrade to a human session.
Notes
- Captcha-protected endpoints require a valid captcha token in the request headers. The specific header name is provided during client SDK initialization.
- claim-username uses
application/x-www-form-urlencodedcontent type, not JSON. Send the username as a form field:curl -X POST https://api.chainabit.com/api/v1/auth/claim-username \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "username=alice_j" - After registration, the user must confirm their email before logging in. The confirmation token is sent to the registered email address.
- The
refreshTokenhas a longer expiry than theaccessToken. Use the/auth/refreshendpoint to obtain new tokens before the access token expires. - The
rememberMeflag on login extends both access and refresh token expiry durations. - Password requirements: minimum 8 characters, maximum 128 characters.
- Magic link tokens expire after 10 minutes and are single-use.
- Social-provider sign-in must continue through its initiating app. Do not treat bearer tokens delivered in a URL as a sign-in result.
- Device flow codes expire after 300 seconds (configurable). Poll at the
intervalrate returned in the authorize response, and complete approval withPOST /auth/device/approvefrom an authenticated browser session. - Developer tokens are opaque, scoped, and time-bounded. Store the raw token in a secret manager and use it directly for permitted automation. It does not prove human verification.