Skip to content

Auth API ​

User registration, authentication, session management, and account security.

Base Path ​

/auth

Authentication ​

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 ​

bash
export REFRESH_TOKEN="your-refresh-token"

Endpoints ​

MethodPathDescriptionAuth
POST/auth/registerRegister a new accountCaptcha
POST/auth/loginPassword verification and server-controlled sign-in admissionCaptcha
POST/auth/logoutInvalidate the current sessionJWT
POST/auth/refreshRefresh access and refresh tokensNone
POST/auth/confirm-emailConfirm email and stage explicit sign-in consentNone
POST/auth/mailbox-login/completeComplete consent with the original receiving-app verifierNone
POST/auth/resend-confirmationResend email confirmationCaptcha
POST/auth/forgot-passwordRequest password reset emailCaptcha
POST/auth/exchange-recovery-codeExchange recovery code for reset tokenNone
POST/auth/reset-passwordSet a new password using reset tokenNone
GET/auth/check-usernameCheck username availabilityJWT
POST/auth/claim-usernameClaim a usernameJWT
POST/auth/change-emailChange account emailJWT
POST/auth/change-passwordChange account passwordJWT
PATCH/auth/profileUpdate user profileJWT
GET/auth/sessionGet current session detailsJWT
POST/auth/magic-linkSend magic link emailCaptcha
POST/auth/magic-link/verifyVerify magic link and stage explicit sign-in consentNone
GET/auth/oauth/providersList OAuth providersNone
GET/auth/oauth/:providerGet OAuth authorization URLNone
GET/auth/oauth/:provider/callbackHandle OAuth callbackNone
POST/auth/oauth/:provider/linkLink OAuth providerJWT
DELETE/auth/oauth/:provider/unlinkUnlink OAuth providerJWT
GET/auth/oauth/linkedList linked providersJWT
POST/oauth/tokenExchange an authorization code or refresh tokenClient auth
POST/oauth/revokeRevoke an OAuth access or refresh tokenClient auth
GET/oauth/userinfoResolve the authenticated OAuth subjectOAuth bearer
POST/auth/device/authorizeGenerate device codesNone
POST/auth/device/approveApprove a CLI device code from an authenticated browser sessionJWT
POST/auth/device/tokenPoll device authorizationNone
GET/auth/developer-tokens/catalogRead the permissions and expiry presets a developer token can useJWT
POST/auth/developer-tokensCreate a time-bounded developer tokenJWT
GET/auth/developer-tokensList developer tokens for the current userJWT
DELETE/auth/developer-tokens/:idRevoke a developer tokenJWT
POST/auth/developer-tokens/exchangeExchange a developer token for a session payloadNone

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-token header.

Request ​

FieldTypeRequiredConstraintsDescription
emailstringYesValid email formatAccount email address
passwordstringYes8-128 charactersAccount password
fullNamestringNoMax 120 charactersUser's full name
referralAttributionTokenstringNoUUIDAttribution token captured from POST /api/v1/referrals/click
referralInviteCodestringNoMax 32 charactersInvite code forwarded during referral-aware signup

Note: referralAttributionToken is optional. Use the value returned by POST /api/v1/referrals/click, not the placeholder shown below.

Response ​

Response Example ​
json
{
  "data": {
    "userId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "email": "alice@example.com",
    "requiresEmailVerification": true
  }
}
Response Fields ​
FieldTypeDescription
userIdstringUnique identifier for the newly created user
emailstringEmail address of the registered account
requiresEmailVerificationbooleanWhether 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-token header.

Request ​

FieldTypeRequiredConstraintsDescription
identifierstringYesMax 256 charactersEmail address or username
passwordstringYesMax 128 charactersAccount password
rememberMebooleanNo--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.

json
{
  "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 ​
FieldTypeDescription
userIdstringUnique identifier for the authenticated user
emailstringEmail address of the account
profileReadybooleanWhether the user has completed profile setup
requiresEmailVerificationbooleanWhether the account still needs to confirm its email
rememberMebooleanWhether the extended session was requested
accountStatus.deletionobject | nullA pending deletion of the account, or null
accountStatus.banobject | nullAn active restriction on the account, or null
authority.scopestringWho the session acts for; person for a person's own sign-in
preferencesobjectThe person's saved preferences, the same object as in GET /auth/session; trimmed in the example above
tokens.accessTokenstringJWT access token for authenticating requests
tokens.refreshTokenstringToken used to obtain a new access token
tokens.expiresInnumberAccess token lifetime in seconds (900 by default)
tokens.tokenTypestringToken scheme (bearer)
tokens.expiresAtnumberUnix timestamp (seconds) when the access token expires
subscription.planCodestringActive subscription plan code
subscription.statusstringSubscription status
profile.usernamestring | nullUsername, 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 ​
json
{
  "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.refreshToken returned by this endpoint. Reusing an older refresh token will return 401 Unauthorized.

Request ​

FieldTypeRequiredConstraintsDescription
refreshTokenstringYes--Refresh token from a previous login or refresh

Response ​

Response Example ​
json
{
  "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 ​
FieldTypeDescription
tokens.accessTokenstringNew JWT access token
tokens.refreshTokenstringNew refresh token (rotated on each refresh)
tokens.expiresInnumberAccess token lifetime in seconds (900 by default)
tokens.tokenTypestringToken scheme (bearer)
tokens.expiresAtnumberUnix timestamp (seconds) when the new access token expires
Client Warning ​
  • Always persist the latest tokens.refreshToken from 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 ​

FieldTypeRequiredConstraintsDescription
emailstringYesValid emailThe account email being confirmed
tokenstringYesMax 128 charsEither the token from the confirmation link, or the shorter printed code
appCodeChallengestringYes43 base64url charactersS256 hash of the receiving app's private codeVerifier

Response ​

json
{
  "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 ​

FieldTypeRequiredConstraintsDescription
challengeIdstringYesUUIDID returned when the email proof was verified
completionTokenstringYes43 base64url charactersCapability returned for that exact confirmation
codeVerifierstringYes43 base64url charactersOriginal private verifier whose S256 challenge was submitted

Response ​

data.statusResult
authenticateddata.session contains the admitted session and its tokens
mfa_requireddata.challenge contains the server-required sign-in verification continuation
recovery_requireddata.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-token header.

Request ​

FieldTypeRequiredConstraintsDescription
emailstringYesValid email formatEmail address to resend confirmation to

Response ​

Response Example ​
json
{
  "data": {
    "message": "Confirmation email sent."
  },
  "meta": null,
  "error": null
}
Response Fields ​
FieldTypeDescription
messagestringHuman-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-token header.

Request ​

FieldTypeRequiredConstraintsDescription
emailstringYesValid email formatAccount email address
redirectTostringNoValid URL, max 300 charactersURL opened by the link in the password reset email

Response ​

Response Example ​
json
{
  "data": {
    "status": "ok"
  }
}
Response Fields ​
FieldTypeDescription
statusstringRequest 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 ​

FieldTypeRequiredConstraintsDescription
codestringYes--Recovery code from the password reset email

Response ​

Response Example ​
json
{
  "data": {
    "accessToken": "YOUR_PASSWORD_RESET_GRANT"
  }
}
Response Fields ​
FieldTypeDescription
accessTokenstringOne-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 ​

FieldTypeRequiredConstraintsDescription
accessTokenstringYesUnexpired, unused grantGrant obtained from the emailed password-reset code exchange
newPasswordstringYes8-128 charactersNew account password

Response ​

Response Example ​
json
{
  "data": {
    "status": "ok"
  }
}
Response Fields ​
FieldTypeDescription
statusstringok 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 ​

ParameterTypeRequiredConstraintsDescription
usernamestringYes3-24 characters, alphanumeric and underscores onlyUsername to check availability for

Response ​

Response Example ​
json
{
  "data": {
    "username": "alice_j",
    "available": true
  },
  "meta": null,
  "error": null
}
Response Fields ​
FieldTypeDescription
usernamestringThe username that was checked
availablebooleanWhether 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-urlencoded content type, not JSON. Send the username as a form field.

Request ​

FieldTypeRequiredConstraintsDescription
usernamestringYes3-24 characters, alphanumeric and underscores onlyUsername to claim

Response ​

Response Example ​
json
{
  "data": {
    "username": "alice_j",
    "claimedAt": "2026-03-17T12:00:00.000Z"
  },
  "meta": null,
  "error": null
}
Response Fields ​
FieldTypeDescription
usernamestringThe username that was claimed
claimedAtstringISO 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 ​

FieldTypeRequiredConstraintsDescription
emailstringYesValid email formatNew email address

Response ​

Response Example ​
json
{
  "data": {
    "status": "pending_verification",
    "email": "alice.new@example.com"
  }
}
Response Fields ​
FieldTypeDescription
statusstringpending_verification until the new address is confirmed
emailstringNormalized 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 ​

FieldTypeRequiredConstraintsDescription
oldPasswordstringYes8-128 charactersCurrent account password
newPasswordstringYes8-128 charactersNew account password

Response ​

Response Example ​
json
{
  "data": {
    "status": "ok"
  }
}
Response Fields ​
FieldTypeDescription
statusstringok 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 ​

FieldTypeRequiredConstraintsDescription
fullNamestringNoMax 50 charactersDisplay name
avatarUrlstringNoValid URLProfile avatar URL
biostringNoMax 160 charactersProfile biography
taglinestringNoMax 60 charactersShort tagline
visibilitystringNopublic or privateProfile visibility setting

Response ​

Response Example ​
json
{
  "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 ​
FieldTypeDescription
usernamestringThe user's claimed username
fullNamestringUpdated display name
avatarUrlstringURL of the profile avatar
biostringUpdated profile biography
taglinestringUpdated short tagline
visibilitystringUpdated 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 ​
json
{
  "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 ​
FieldTypeDescription
user.idstring (uuid)Unique identifier for the user
user.emailstringEmail address of the account
profile.usernamestring | nullClaimed username
profile.fullNamestring | nullDisplay name
profile.avatarUrlstring | nullURL of the profile avatar
profile.biostring | nullProfile biography
profile.taglinestring | nullShort tagline
profile.visibilitystring | nullProfile visibility (public or private)
profile.isReadybooleanWhether the profile setup is complete
profile.onboardingobject | nullOnboarding progress: status (string) and currentStep (number)
profile.badgeobject | nullChainer badge: rank (number), tier (string or null) and awardedAt (ISO 8601 timestamp)
preferencesobjectThe user's saved preferences (notifications, language, timezone, AI behaviour and view settings); the fields are shown in the example
subscription.planCodestringActive subscription plan code
subscription.planNamestringDisplay name of the plan
subscription.variantIdstring (uuid)Identifier of the active plan variant
subscription.statusstringSubscription status
subscription.providerstring | nullPayment provider of the active subscription, or null
defaultAccount.idstring (uuid)Identifier of the person's own account
defaultAccount.namestringName of the default account, by the same rule as workspaces[].accountName
defaultAccount.slugstring | nullSlug of the default account's default workspace
workspaces[].idstring (uuid)Unique identifier for a workspace
workspaces[].accountIdstring (uuid)Owning account. Send it as x-account-id to act in that account
workspaces[].namestringName of the workspace itself. Default workspaces of different organizations can share a name
workspaces[].accountNamestring | nullName 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[].slugstringURL slug of the workspace
workspaces[].isDefaultbooleanWhether it is the default workspace of its account
workspaces[].productModestringpersonal, business or unavailable
workspaces[].businessLifecyclestringPresent for business workspaces: active, restricted, onboarding_required or legacy_review
identity.hasPasswordbooleanWhether the account has a password
identity.linkedProviders[]string[]Sign-in providers linked to the account
authority.scopestringperson (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 ​

FieldTypeRequiredDescription
emailstringYesEmail address to send the magic link to
redirectTostringNoURL to redirect after verification

Response ​

Response Example ​
json
{
  "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 ​

FieldTypeRequiredDescription
tokenstringYesMagic link token from the email
emailstringYesEmail address used when sending
appCodeChallengestringYes43-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 ​
json
{
  "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 ​

ParameterTypeDescription
redirectTostringOptional redirect URL after linking

Response ​

Response Example ​
json
{
  "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"

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 ​
json
{
  "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 ​
json
{
  "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:

FieldTypeRequiredDescription
namestringNoDevice display name such as chainabit-cli
deviceTypestringNoClient type such as cli
appVersionstringNoClient version for audit and support diagnostics
settingsobjectNoFree-form client metadata

Response ​

Response Example ​
json
{
  "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/authorize

POST /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 ​

FieldTypeRequiredConstraintsDescription
userCodestringYesXXXX-XXXXUser-facing device code shown by the CLI

Response ​

Response Example ​
json
{
  "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 ​

FieldTypeRequiredDescription
deviceCodestringYesDevice code from the authorize response

Response ​

Response Examples ​

Pending:

json
{ "data": { "status": "authorization_pending" } }

Expired:

json
{ "data": { "status": "expired" } }

Approved (schematic):

text
{
  "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 ​

FieldTypeRequiredConstraintsDescription
labelstringYesmax 80 charactersFriendly name such as GitHub Actions
expiresInDaysnumberNo1-365, default 30Lifetime of the developer token

Response ​

Response Example ​
json
{
  "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 ​

json
{
  "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 ​

json
{
  "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-urlencoded content 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 refreshToken has a longer expiry than the accessToken. Use the /auth/refresh endpoint to obtain new tokens before the access token expires.
  • The rememberMe flag 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 interval rate returned in the authorize response, and complete approval with POST /auth/device/approve from 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.

Built with purpose. chainabit.com