Claxx Auth
Docs
Sign in
User FAQ
  • Reset my password
  • I can't sign in
  • Didn't get reset email
  • Account linking
  • Session expiry
  • Two-factor auth
Admin Guides
Theme Studio
  • Overview
  • Layouts
  • Styling tokens
  • Concept copy
  • Assets & backgrounds
  • Advanced CSS
Admin Shell
  • Users
  • Providers
  • Clients
  • Invitations
Integrations
  • OIDC flow
  • Provider token brokering
  • Email triggers
  • Webhook events
  • Session contract
Reference
  • API
  • Error codes
  • Event shapes
  • Design tokens

API Reference

Claxx Auth exposes four distinct surfaces, each with its own conventions:

  1. Protocol endpoints — OIDC (/api/oidc/**), provider sign-in routes (/oauth2/**), and discovery (/.well-known/**). These return spec-compliant payloads, not Claxx Auth's envelope.
  2. Auth JSON API — /api/auth/**. Session-cookie authenticated. Returns the Claxx Auth envelope.
  3. Admin JSON API — /api/admin/**. Admin-role required. Returns the Claxx Auth envelope. CSRF-protected via session cookie.
  4. Provider token brokering — /api/provider-tokens/**. Bearer-token authenticated. Returns the Claxx Auth envelope.

All JSON APIs wrap success/error responses in the canonical envelope documented in Response envelopes. Protocol endpoints follow their respective RFCs.

Response envelopes

Success

{
    "success": true,
    "data": { "...": "resource or collection" },
    "meta": {
        "pagination": { "page": 1, "pageSize": 20, "total": 143, "totalPages": 8 },
        "count": 20,
        "hasMore": true
    }
}

meta is present on list endpoints only. debug is attached in non-production stages and includes timestamp, service, and version.

Error

{
    "success": false,
    "error": {
        "code": "VALIDATION_ERROR",
        "message": "Human-readable message",
        "status": 400,
        "requestId": "req_01H...",
        "fields": { "email": { "code": "invalid_format", "message": "Invalid email" } }
    }
}

fields is present only on VALIDATION_ERROR responses derived from Zod issues. debug is present in non-production stages with stack, cause, timestamp, service, and version. See the Error Codes reference for every code.

Authentication

SchemeWhere it appliesCredential
Session cookie/api/auth/**, /api/admin/**Better Auth session cookie issued by /api/auth/sign-in/* or OAuth callback
Admin role/api/admin/**Session belongs to a user with role = 'admin' (enforced via requireAdminRole)
Admin key/api/admin/**Bearer token of a service client with the admin scope. See Admin keys
OAuth Bearer/api/oidc/userinfo, /api/provider-tokens/:providerAuthorization: Bearer <access_token> issued by /api/oidc/token
Client authentication/api/oidc/token, /api/oidc/token/introspect, .../revokeprivate_key_jwt only, for every client: see Client authentication
Cross-origin public/.well-known/**, /api/oidc/jwksNone. Readable from any origin. No other route answers a cross-origin request: a page on another origin cannot read this API.

OIDC endpoints

All OIDC endpoints return spec-compliant payloads. Errors follow OIDC Core / OAuth 2.0 conventions ({"error": "...", "error_description": "..."}), not the Claxx Auth envelope. error_description is one fixed sentence per error code; the reason for a particular refusal goes to the audit log, not to the caller.

MethodPathPurpose
GET/.well-known/openid-configurationDiscovery document
GET/api/oidc/authorizeStart authorization-code flow
POST/api/oidc/tokenExchange code for tokens (or client_credentials)
POST/api/oidc/token/introspectIntrospect an access token (RFC 7662)
POST/api/oidc/token/revokeRevoke an access token (RFC 7009)
GET | POST/api/oidc/userinfoGet user claims (Bearer-authed)
GET/api/oidc/jwksPublic keys for ID-token signature verification
GET/api/oidc/end-sessionRP-Initiated logout (OpenID Connect RP-Initiated Logout 1.0)

GET /.well-known/openid-configuration

Discovery document. Returns:

{
    "issuer": "https://auth.claxx.gg",
    "authorization_endpoint": "https://auth.claxx.gg/api/oidc/authorize",
    "token_endpoint": "https://auth.claxx.gg/api/oidc/token",
    "userinfo_endpoint": "https://auth.claxx.gg/api/oidc/userinfo",
    "jwks_uri": "https://auth.claxx.gg/api/oidc/jwks",
    "introspection_endpoint": "https://auth.claxx.gg/api/oidc/token/introspect",
    "revocation_endpoint": "https://auth.claxx.gg/api/oidc/token/revoke",
    "end_session_endpoint": "https://auth.claxx.gg/api/oidc/end-session",
    "scopes_supported": ["openid", "profile", "email"],
    "response_types_supported": ["code"],
    "grant_types_supported": ["authorization_code", "client_credentials"],
    "subject_types_supported": ["pairwise"],
    "id_token_signing_alg_values_supported": ["ES256"],
    "token_endpoint_auth_methods_supported": ["private_key_jwt"],
    "token_endpoint_auth_signing_alg_values_supported": ["ES256"],
    "code_challenge_methods_supported": ["S256"],
    "authorization_response_iss_parameter_supported": true
}

GET /api/oidc/authorize

Start the OIDC authorization-code flow. On success, redirects the user agent to redirect_uri with code, state and iss (this issuer, RFC 9207). Every error sent to redirect_uri carries iss too.

Query parameters:

ParamRequiredNotes
client_idyesUUID. Must match an active row in oauth_clients
redirect_uriyesExactly one of the client's registered redirectUris (see below)
response_typeyesMust be code
scopeyesSpace-delimited. Must include openid; all requested scopes must be in allowedScopes
stateyesOpaque relay value
nonceyesRequired — rejected if missing
code_challengeyesRequired (PKCE enforced)
code_challenge_methodyesMust be S256

Redirect addresses: redirect_uri, and post_logout_redirect_uri at /api/oidc/end-session, are matched exactly. Each side is normalized as a URL parser does (new URL(value).href) and the two must be equal: the scheme, host, port and path the same, a host in capitals the same host, a trailing slash or an added query a different address. Nothing is a pattern. Only an absolute https: address qualifies, or http: on localhost, 127.0.0.1 or [::1], with no user name, password, fragment, query or *, and a host of letters, digits, dots, hyphens and underscores (or an IPv6 address in brackets); an address that breaks this matches nothing, even a stored one. A redirect_uri that matches nothing is answered 400 VALIDATION_ERROR (Invalid redirect_uri) on this host.

Behavior:

  • A service application is refused with 400 { "error": "unauthorized_client" } on this host: it signs nobody in and has no redirect URI to send the error to.
  • A request without openid is refused with invalid_scope, sent to the redirect URI.
  • A request for the admin scope is refused with invalid_scope, whatever the client's allowedScopes list.
  • The code works once and lives 60 seconds. Only its SHA-256 is stored.
  • If the session is unauthenticated, redirects to /login?unauthorized=true&client_slug=<slug> and stores returnTo as the OIDC continuation so the user is returned to authorize after login.
  • If the session requires a password reset, redirects to /reset-password with continuation state.
  • If the session was made in a way this client's sign-in rules do not accept, no code is issued. The browser is sent to /login?client_slug=<slug>&reauth=true&reason=<reason> for a fresh sign-in, and comes back here after it. The rules are read from what the session recorded when it was created, so a sign-in through a lenient client does not open a strict one. reason is one of: password_not_allowed (opened by password, and the client takes no passwords), second_factor_required or second_factor_setup_required (opened by password without the code step, the client requires one, and the account has a second factor or has none yet), passkey_not_allowed (opened by passkey, and the client takes no passkeys), email_link_not_allowed (opened by an emailed link, and the client does not offer links). With prompt=none the answer is login_required.

POST /api/oidc/token

Exchange an authorization code for tokens, or mint a client_credentials token.

Authentication: private_key_jwt, the only method (see Client authentication). A client that cannot be authenticated gets 401 {"error": "invalid_client"}.

Body (authorization_code): grant_type=authorization_code&code=<code>&redirect_uri=<uri>&code_verifier=<verifier>

The code is taken out of the store by a single DELETE ... RETURNING: of two requests with the same code exactly one gets tokens, and a request that then fails a check (expired after 60 seconds, another client, another redirect_uri, a wrong code_verifier) has used the code up all the same. All of these answer 400 invalid_grant.

Body (client_credentials): grant_type=client_credentials. Only a service client can use this grant; any other is answered 400 unauthorized_client. The token carries the client's allowedScopes.

A service client may use client_credentials only: authorization_code answers 400 unauthorized_client.

Response:

{
    "access_token": "...",
    "id_token": "...",
    "token_type": "Bearer",
    "expires_in": 3600
}

client_credentials tokens carry sub = client_id with no user claims.

The access token's header is typ: at+jwt (RFC 9068) and the ID token's typ: JWT. Both are ES256, signed by the current signing key. For authorization_code both live as long as the sign-in they came from has left, 3600 seconds at most, and expires_in says how long; a code whose sign-in has ended (signed out, revoked, expired) gets invalid_grant. client_credentials tokens live 3600 seconds.

Client authentication

Every endpoint that authenticates a client (token, introspection, revocation, sign-in link, session check and revoke) takes the same private_key_jwt assertion (RFC 7523): client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer and client_assertion=<JWT>, with client_id optional.

  • Header: alg ES256 (any other algorithm is refused), kid the client's assertion key ID.
  • iss and sub: the client ID. aud: this issuer's token endpoint, or the URL of the endpoint being called.
  • jti, iat and exp are all required. exp at most five minutes ahead, iat neither in the future nor more than five minutes ago, each with 60 seconds of clock difference allowed; an exp already passed is refused.
  • Used once: the jti is recorded per client in the verifications table (row id from the client id and a SHA-256 of the jti) until the assertion expires. A second use, on any instance, is 401 invalid_client.

There is no client_secret_basic or client_secret_post.

Responses set Cache-Control: no-store and Pragma: no-cache per OAuth 2.0 §5.1.

POST /api/oidc/token/introspect

RFC 7662. Authenticates the client, then returns the introspection response.

Body: token=<access_token>&token_type_hint=access_token

Response (active):

{
    "active": true,
    "sub": "<pairwise-subject-or-client-id>",
    "client_id": "<client-uuid>",
    "scope": "openid profile email",
    "token_type": "Bearer",
    "exp": 1713283200,
    "iat": 1713279600
}

Returns {"active": false} when the token is unknown, expired, belongs to a different client, is not an access token signed by this issuer (typ: at+jwt, a published key), or has stopped working:

  • issued to a person: the sign-in the token came from has ended (its session at this service, on the client's tenant, is gone or past its end: the person signed out here or through /api/oidc/end-session, a password change or completed reset ended it, a passkey removal or an admin ended it, the account was marked to choose a new password or removed, or the sign-in's own time ran out), the account is deleted, the client is switched off or deleted, or the person was signed out of the client (/api/oidc/session/revoke or the admin action) after that sign-in. The sign-in is read in the same statement as the token's row, so this costs no extra round trip;
  • a client_credentials token: the client is switched off, deleted or no longer of type service.

A client that is switched off or deleted cannot authenticate, so it gets 401 invalid_client rather than an answer.

POST /api/oidc/token/revoke

RFC 7009. Always returns HTTP 200 with {"ok": true}, regardless of whether the token existed. Only revokes tokens that belong to the authenticating client. A client that cannot be authenticated gets 401 {"error": "invalid_client"}.

Body: token=<access_token>&token_type_hint=access_token

POST /api/oidc/sign-in-link

Emails one of the client's users a one-time sign-in link. Client authentication as at the token endpoint; a client assertion's aud is this endpoint's URL. Needs Allow sign-in by emailed link on the client.

Body: email=<address>&expires_in=<seconds, 900 to 86400, default 3600> (a shorter or longer value is taken as the nearest bound)

Response: 202 {"accepted": true, "expires_in": 3600}, the same whether or not the address has an account. Only an account that belongs to the client's tenant (docs/runbooks/tenant-membership.md) is sent a link; any other address gets the same answer and nothing is sent. At most one link a minute and three per link lifetime go to one account on one tenant; past that nothing is sent, the answer is the same, and the newest link sent still works. Errors use the token endpoint's shape: invalid_client (401), unauthorized_client (400, links not switched on, or a public or service client), invalid_request (400), slow_down (429). See Sign-in links.

POST /api/oidc/session/revoke

Signs one person out of the calling client on every device: every sign-in of theirs made before this moment stops counting for that client. Their session at this service and at other clients is not touched.

Body: sub=<the person's subject in this client's ID tokens>

Response: 200 {"revoked": true, "revoked_before": <unix seconds>}. A public or service client gets 400 unauthorized_client.

POST /api/oidc/session/check

Whether a sign-in the client holds a session for still counts.

Body: sub=<subject>&auth_time=<auth_time of the ID token>&sid=<sid of the ID token>, all three from the ID token the client's session came from. A missing or malformed sub or auth_time is 400 invalid_request; a missing sid is 400 sid_required (what an application on @claylevering/auth-nuxt 0.3.x gets: upgrade to 0.4.0).

sid is the session id sealed for this one client (AES-GCM under a key derived for the client): opaque, different at every client for the same sign-in, and opened only by this client's own check. A sid of another client, an altered one, or a session id itself is a sign-in of nobody: {"active": false}.

Response: 200 {"active": true | false}. true only while the sign-in lives: the session sid names exists on this client's tenant and has not ended, it is the session of the person sub names and of that auth_time, and the person was not signed out of this client after it. false means the sign-in has ended (signed out, ended by a password change or reset, a passkey removal, an admin, the mark to choose a new password, or its own time) or was revoked for this client; end the client's own session. One database statement, whatever the answer. A service client gets 400 unauthorized_client. See Signing a person out.

GET / POST /api/oidc/userinfo

Returns claims for the authenticated user. Requires Authorization: Bearer <access_token>.

The token must be an access token this issuer signed (typ: at+jwt: an ID token is refused), unexpired, issued on this tenant, and still good by the rule under POST /api/oidc/token/introspect: the sign-in it came from still live, the account not deleted, the client active and not deleted, and the person not signed out of the client since the sign-in. Anything else is 401 with WWW-Authenticate: Bearer error="invalid_token" and {"error": "invalid_token", "error_description": "The access token is not valid."} (no token at all: WWW-Authenticate: Bearer).

Claims returned reflect scopes granted to the token:

  • openid — sub
  • profile — name, given_name, family_name, picture, preferred_username
  • email — email, email_verified

GET /api/oidc/jwks

Returns the signing-key JWKS for verifying Claxx Auth-issued ID tokens. Keys are ES256 on P-256. It lists the key that signs now and any key retired by a rotation whose tokens may still be live. An admin rotates the key (POST /api/admin/signing-keys/generate, under Admin JSON API below); the previous key stays published for an hour (the longest token lifetime), plus five minutes (another instance may still sign with its cached copy), plus a minute of clock difference, then is retired. A key withdrawn by an admin (POST /api/admin/signing-keys/retire) leaves the JWKS at once. The response may be cached for five minutes. Fetch the JWKS again on an unknown kid.

The response carries Cache-Control: public, max-age=300: any cache may keep it for five minutes and no longer. A new key signs from the moment it is created, so a key set older than that may not hold the key a fresh token names.

GET /api/oidc/end-session

RP-Initiated Logout (OpenID Connect RP-Initiated Logout 1.0). Clears the Better Auth session cookie, deletes the session row, then redirects.

Query parameters:

ParamRequiredNotes
id_token_hintnoPreviously issued ID token
post_logout_redirect_urinoFollowed only if it is exactly one of the post-logout redirect URIs of an active client of this tenant (matched as redirect_uri is at /authorize). The session ends either way; with an address nobody registered, the person lands on this host, signed out
statenoOpaque value relayed to the RP

Provider sign-in routes

Sign-in through an outside provider (Google, GitHub, Microsoft, a custom OIDC provider). The hosted sign-in page, the profile page and the invitation page start it. An application signs people in with the OIDC flow, not with these routes.

MethodPathPurpose
GET/oauth2/loginStart a sign-in at the provider
GET | POST/oauth2/callbackReturn from the provider, sign in, and redirect to returnTo

GET /oauth2/login

Query parameters:

ParamNotes
providerrequired. The slug of an active provider of this host's tenant
returnTowhere to go when done. A path on this service, or an address registered as a redirect URI by an active client of this tenant (see below)
intentinvite to claim an invitation. link is refused here (400): connecting a provider starts at POST /api/auth/link-provider
invitation_tokenrequired when intent=invite
client_idrequired for client-bound consent and scope escalation. An absolute returnTo must then match one of that client's redirect URIs
additional_scopesspace-delimited. Merged with the provider's base scopes; only for a client whose allowedProviderTokens names the provider
promptOIDC prompt value, downgraded against the provider's prompt_values_supported

returnTo rules:

  • A path must start with one / followed by a character that is not / or \, and contain no backslash and no control character. //host, /\host and /<tab>/host are refused.
  • An absolute address must be exactly a registered redirect URI of an active client of this tenant (of the named client when client_id is given), matched as redirect_uri is at /authorize, or have exactly this service's origin. An address that only begins with this service's origin text, such as https://login.example.test.evil.example or https://login.example.test@evil.example, is refused.
  • Anything else is refused with 400 before the provider is contacted.

On success the browser is sent to the provider. The response sets a cookie, claxxauth_oauth_state (HttpOnly, SameSite=Lax, Path=/oauth2, Secure on https, ten minutes), holding a SHA-256 hash of the state sent to the provider. The state's record (PKCE verifier, nonce, returnTo, intent) is stored encrypted in the verifications table for ten minutes.

When intent=invite, the invitation token is checked first, and a provider that the invited client does not offer is refused.

A session alone never connects a provider: someone holding a session (signed in with a leaked password) could connect their own identity at the provider and keep a way in after the password changed. Connecting asks for the password again (POST /api/auth/link-provider), which then starts this same flow with intent=link for the signed-in account.

GET/POST /oauth2/callback

  1. The state must be one this browser started: its hash must be in the claxxauth_oauth_state cookie, and its record is taken with a single delete, so it works once. Otherwise the browser goes to /login?error=invalid_state. The cookie is cleared either way.
  2. The code is exchanged with the provider.
  3. The account is decided:
    • A provider identity already connected to an account signs that account in.
    • An identity that is not connected is never attached to an account because the address matches. If any account uses the address (as its sign-in address or as any recorded address, confirmed or not), the sign-in is refused with reason=account_exists. The owner signs in another way and connects the provider from /profile.
    • A new account is made only when no account uses the address and the provider says it confirmed the address (email_verified). Otherwise reason=email_not_verified.
    • With intent=link (started by POST /api/auth/link-provider), the provider is connected to the signed-in account the flow was started for, in the browser it was started in. A provider identity connected to a different account is refused, and so is a browser that is no longer signed in as that account.
    • A deleted account is never signed in or connected to (reason=account_unavailable).
    • An account marked to choose a new password gets no session: the browser goes to /login?error=session_failed&reason=password_reset_required, and the account is emailed the link to choose one (at most once every 15 minutes). No invitation is accepted and no provider token is granted.
  4. With intent=invite, the invitation must still be pending, the provider must be offered by the invited client, and the provider must have confirmed the invited address itself. Otherwise reason=invitation_email_mismatch (or the matching invitation reason), before any account is made or connected. On success the browser goes to the invitation's onboarding path.
  5. A session is issued, user.created, account.linked and session.created are published, and returnTo is checked again with the same rules before the redirect. A returnTo that fails goes to /profile?error=redirect_not_allowed.

Every answer is a redirect. When the provider reports an error (error=access_denied and others), the browser goes back to an absolute returnTo only if it passes the same checks, with error=consent_denied or error=provider_error; otherwise to /login. Refusals go to /login?error=session_failed&reason=…, to /profile?error=link_failed&reason=… for intent=link, and to /invite?…&error=session_failed&reason=… for intent=invite.


Auth JSON API

Session-authenticated. All endpoints return the canonical envelope unless noted.

MethodPathAuthPurpose
GET/api/auth/providerspublicProviders visible for client_slug (or default)
GET/api/auth/client-policypublicHosted-login password/signup policy for a client
GET/api/auth/invitation-contextpublicResolve invitation status and themed client context
GET/api/auth/themepublicResolve theme by client_slug or theme_id
GET/api/auth/linkable-providerssessionAll active providers the user may link
POST/api/auth/link-providersessionConnect a provider: the password again, then the provider
GET/api/auth/security-statesessionSession metadata: user, requirePasswordReset, role
GET/api/auth/second-factor/statussessionThe account's second factors here, and what this session proved
POST/api/auth/second-factor/verifysessionProve the authenticator app (or a backup code) on this session
POST/api/auth/second-factor/passkey/optionssessionStart proving a passkey of this account on this session
POST/api/auth/second-factor/passkey/verifysessionFinish proving a passkey on this session
GET/api/auth/sessionssessionThe signed-in person's sessions on this tenant
POST/api/auth/sessions/endsessionSign out one of their other sessions on this tenant
POST/api/auth/sessions/end-otherssessionSign out every other session, on every tenant
POST/api/auth/session-contextsessionStamp a clientSlug onto the active session
POST/api/auth/change-passwordsessionChange password for the authenticated user
POST/api/auth/delete-accountsessionThe signed-in person deletes their own account
POST/api/auth/accept-invitepublicAccept an invitation: new account, or signed-in owner
ALL/api/auth/[...all]mixedBetter Auth catch-all (sign-in, sign-up, reset, etc.)

POST /api/auth/link-provider

Body: { "provider": "<slug>", "password": "string" } (strict). Connects an outside sign-in provider of this host's tenant to the signed-in account. The password is asked for again, as for adding a passkey, and counted like a sign-in try (a wrong one counts towards the address's lock; while it is locked the answer is 429). On success: { success: true, data: { url } }, the provider's sign-in page; the browser goes there and comes back to /oauth2/callback, which connects the identity to this account (returnTo is /profile). Refused: 401 not signed in, wrong password; 400 the account has no password of its own (it cannot add a further way in from its profile); 404 no such active provider on this host. An account marked to choose a new password has no session here (401). The owner is emailed when a provider is connected.

An account that has a password of its own stays a password account whatever it connects: its password, passkeys and emailed sign-in links keep working. Only an account with a provider and no password is the provider's (the service setting allowPasswordForSsoUsers then decides whether a credential of this service may sign it in too).

GET /api/auth/providers

Query: client_slug (optional — defaults to default).

Response: { success: true, data: ProviderInfo[] } where each item has { slug, name, type, buttonText, styleVariant, iconUrl }. Cached in Cache for the PROVIDER_LIST TTL.

GET /api/auth/client-policy

Query: client_slug (optional — defaults to default).

Response: { success: true, data: { clientSlug, passwordAuthEnabled, selfServiceSignupEnabled, requireMfaForPasswordAuth, emailLinkAuthEnabled } }. emailLinkAuthEnabled is true only when the sign-in page should offer Email me a sign-in link: the client's switch is on, it accepts passwords, and it does not require a second factor.

Use this to drive hosted-login UX. Provider listings and password/signup policy are intentionally separate: /api/auth/providers tells you which upstream providers to render, while this endpoint tells you whether Claxx Auth should render or accept credential auth for that client_slug.

GET /api/auth/invitation-context

Query: token (required).

Response: { success: true, data: { status, tokenValid, email?, clientSlug?, clientName?, onboardingPath?, requiredProviderKeys, passwordAllowed, accountExists, signedInAsInvitee } }.

This is the public preflight for /invite. It lets the hosted page resolve the correct client branding and invitation state before the user sets a password or begins upstream sign-in.

accountExists is true when an account already uses the invited address (a deleted account does not). signedInAsInvitee is true when the request carries a session, opened on this tenant's host, for that account. The page uses them to choose its form: a password form for a new account, Sign in for an existing account, or a single Accept invitation button when signed in as it. Both are false unless the invitation is pending. Nothing else about the account is returned.

GET /api/auth/theme

Query: exactly one of client_slug or theme_id. theme_id takes priority.

Response: resolved theme payload — see Design Tokens for the full field list. Cached under CacheKey.theme(clientSlug).

GET /api/auth/linkable-providers

Requires session. Returns all active providers the authenticated user could link.

GET /api/auth/security-state

Returns:

{
    "success": true,
    "data": {
        "authenticated": true,
        "isAdmin": true,
        "requirePasswordReset": false,
        "secondFactorProved": false,
        "adminSecondFactor": { "status": "proof_required", "canProveHere": true, "methods": { "authenticator": true, "passkey": false }, "onlyElsewhere": false },
        "user": { "id": "...", "email": "...", "name": "...", "role": "user" }
    }
}

secondFactorProved is true when this session proved two factors, when it was opened or since. adminSecondFactor is null for someone who is not an admin on this host. For an admin, status is not_required (the security policy has the rule off here), satisfied, setup_required (no second factor at all, on any site) or proof_required (one this session did not prove); canProveHere is false when a factor proved on this session would not count for it, and the person has to sign in again with the password and the second factor. methods are what can be proved on this site; onlyElsewhere is true when the account's only second factor is a passkey of another site, and the screen offers an emailed sign-in link instead.

Changing a second factor, once the account has one

With a second factor on the account (a confirmed authenticator app, or a passkey made for any site: the account is shared by every site), the password alone changes nothing about it. When the account's only factor is a passkey of another site, nothing can be proved on this one, and only a session an emailed sign-in link opened, with the password, changes its factors here. POST /api/passkey/register/options and /verify (add a passkey), POST /api/passkey/:id/remove, POST /api/auth/two-factor/enable (on again or replaced, with new backup codes) and /disable answer 403 SECOND_FACTOR_REQUIRED to a session that has not proved two factors, unless an emailed sign-in link opened it and the account's password is older than it and older than every second factor the account has now, on any site (the mailbox alone can choose a new password, so a password chosen after the factor was added does not count there). The answer comes before the password in the request is looked at; the try is not counted. On a signed-in session POST /api/auth/two-factor/verify-backup-code is always refused, and /two-factor/verify-totp when the app is confirmed already: prove a code through /api/auth/second-factor/verify instead. Adding a factor raises the session that added it only when it is the account's first.

GET /api/auth/second-factor/status

{ hasFactor, methods: { authenticator, passkey }, onlyElsewhere, proved, canProveHere, linkRecovery }: whether the signed-in account has a second factor on any site, what it can prove with on this one (onlyElsewhere: nothing; its only factor is a passkey of another site), whether this session has proved two factors, whether a factor proved on this session would count for it, and whether an emailed sign-in link with the password could change its factors (linkRecovery: false when the password was changed after the factor was added; an administrator must help).

POST /api/auth/second-factor/verify

Proves the account's authenticator app on the session that is already signed in, and records that the session has now proved two factors. Body: { "code": "123456", "kind": "totp" }, or "kind": "backup" with one of the backup codes (which is then used up). Each try is counted in the same lock as the second step of sign-in: a wrong code is 400, and past the security policy's limit 429 RATE_LIMITED with Retry-After and the wait in the message; a wrong code here counts towards the sign-in's lock too. 403 when a factor proved on this session would not count for it: the session was opened by an emailed link or an identity provider, and the account's password was set after that (sign in again instead). 422 when the account has no authenticator app. Answers { "proved": true }.

POST /api/auth/second-factor/passkey/options and /verify

The same with a passkey. options (body {}) answers { proved: false, options }, WebAuthn request options that offer only this account's passkeys made for this host, with user verification required; the challenge lasts five minutes and is used once. verify takes { "response": <the browser's answer> }. The passkey must be this account's, made for this host, and the device must have verified the person; every answer is counted in the second step's lock. A passkey of another account or another host, or an answer without user verification, is 400 and proves nothing.

Adding a factor on a session also counts: confirming a newly added authenticator app (the first code after two-factor/enable, which asks for the password), or adding a passkey (/api/passkey/register/*, which asks for it twice), raises the session that did it, under the same rule as above.

GET /api/auth/sessions

The signed-in person's live sessions on this tenant, the most recently used first: { sessions: [{ id, device, ipAddress, openedAt, lastUsedAt, current }] }. device is the browser and system in plain words ("Chrome on macOS"); openedAt is when the person signed in; lastUsedAt is written at most every five minutes; current marks the session of the browser asking. Never another account's sessions, never another tenant's, never a session's cookie value; id is the session's row id, which signs nobody in.

POST /api/auth/sessions/end and /end-others

end with { "id": "..." } signs out one of the person's other sessions on this tenant. A session of another account, of another tenant, or that does not exist is 404, all alike; the browser's own session is 400 (sign out instead). end-others with {} signs out every other session of the account on every tenant and answers { ended }. POST, not DELETE: on Workers the body of a DELETE never arrives.

What applications were given from an ended session goes with it: the access tokens issued from that sign-in (the account and the sign-in time, at the session's tenant's applications) are deleted, and with them the codes not yet exchanged. An access token is checked against its stored row on every use, not against the session it came from, so without this a token would keep working for up to an hour after its session ended. end-others keeps only the tokens of the browser's own sign-in. Each ended session is recorded as auth.session.revoked (metadata.reason ended_by_owner or signed_out_everywhere_else, metadata.target_id the session id), under the tenant the session belonged to.

POST /api/auth/session-context

Body: { "clientSlug": "string" }. Writes clientSlug onto the current sessions row so downstream telemetry and webhook emissions can carry the initiating client.

POST /api/auth/delete-account

The signed-in person deletes their own account. Body: { "password": "..." }, the account's password, asked for again. 401 for a wrong password, 400 for an account with no password (an admin deletes those), 403 for the platform's configured admin, for the last account with the admin role, and for an account marked to choose a new password (its password is not accepted until a new one is chosen; the try is not counted). On success the account is emptied as an admin's delete empties it: its sessions on every tenant, password, passkeys, second factor, linked identities and outstanding tokens are removed, and the address is free again. Rate-limited with the password change.

A person cannot change the address they sign in with; an admin changes it.

POST /api/auth/change-password

Body: { "currentPassword": "string", "newPassword": "string (12 to 128 characters)" }. Verifies against the current credential account, enforces the password policy (incl. pwned-password checks when enabled in service_settings), then clears requirePasswordReset, ends the account's other sessions on every tenant and spends every reset, setup and sign-in link it still has.

currentPassword may be left out in one case only: the session was opened by an emailed sign-in link, and the account has no password yet or has been told to choose a new one. GET /api/auth/security-state reports that case as canSetPasswordWithoutCurrent: true.

An account told to choose a new password (requirePasswordReset) has no session except one an emailed sign-in link opened after the mark, and that one does exactly one thing: choose the new password here, without currentPassword. To every other route it is no session: the profile and passkey routes, the admin API, /api/oidc/authorize, /api/auth/accept-invite, /api/auth/link-provider and every engine route that acts on a session (/get-session answers null, /list-accounts, /update-user, /two-factor/enable and /disable answer 401) treat the request as signed out; /sign-out still ends it. This is decided where the session is read (server/utils/auth.ts, SessionLookup; the engine's route takes the session cookie out first), so a new route cannot forget it. Any other session of a marked account is no session for anything. The current password is never looked at or counted while the account is marked. The new password is chosen through the emailed link (POST /api/auth/reset-password), or here from the emailed sign-in link's session. A sign-in through an identity provider opens no session for a marked account; it emails the link (at most once every 15 minutes).

A password change keeps this browser signed in and remembered, ends every other session on every tenant and forgets every other browser the account signed in from (known_devices), so none keeps a password-try count of its own.

Errors: AUTHENTICATION_REQUIRED if current password doesn't match; VALIDATION_ERROR if password policy fails.

POST /api/auth/email-link/request

The Email me a sign-in link button on the hosted sign-in page.

Body: { "email": "string", "clientSlug": "string" }.

Response: { success: true, data: { status: true, validForSeconds: 900 } }, the same whether or not the address has an account; the email is sent after the response. 403 when the client does not offer sign-in links.

POST /api/auth/email-link/consume

Signs the browser in with the token from an emailed link. The sign-in link page calls it when the person presses Sign in; opening the link does not.

Body: { "token": "string" }.

Response: { success: true, data: { redirectTo, requirePasswordReset } }. redirectTo is the client's sign-in start URL, or a page on this service when the client has none. Every failure is the same 400: the link has expired or was already used.

POST /api/auth/accept-invite

Body: { "token": "string", "password"?: "string (12 to 128 characters)" }. Returns { userId, clientSlug, onboardingPath }. What happens depends on whether an account already uses the invited address:

  • No account uses it. password is required. It must pass the password policy (at least 12 characters, at most 128, and not found in known data breaches when blockPwnedPasswords is on). The invitation is claimed first, with one conditional update from pending to accepted; then the account is created with its address marked verified, invitation.accepted is published and a session is issued. If creating the account or the session fails, the invitation goes back to pending.
  • An account uses it. The invitation never sets that account's password and never issues a session for it. The request must already carry a session, opened on this tenant's host, for that same account; the invitation is then accepted for it and password is ignored. Otherwise the answer is 401 with code SIGN_IN_REQUIRED and the message "An account already uses this address. Sign in, then open your invitation link again." Signed in as a different account gets the same answer.

An invitation is accepted once. Of several requests with the same token at the same moment, exactly one succeeds; the others get 409 RESOURCE_CONFLICT ("This invitation has already been accepted"). A later request gets 400.

Errors: VALIDATION_ERROR (400) for an unknown, accepted, revoked or expired invitation, a missing password for a new account, or a password outside 12 to 128 characters; BUSINESS_RULE_VIOLATION (422) for a breached password; SERVICE_UNAVAILABLE (503) when the breached-password check cannot be reached; SIGN_IN_REQUIRED (401) and RESOURCE_CONFLICT (409) as above.

If an invitation requires one or more providers, this endpoint rejects the password path with a validation error and the invite must be claimed through that provider instead.

Invite links can also be claimed through a provider with intent=invite (see /oauth2/callback under Provider sign-in routes). The provider must be offered by the invited client, must be one of the invitation's required providers when it names any, and must confirm the invited address itself. A provider that gives another address, or does not confirm it, does not accept the invitation, and no address is recorded for whoever signed in.

ALL /api/auth/[...all]

Better Auth catch-all. Handles sign-in/sign-up, forgot-password, reset-password, email-verification, and all standard credential flows. Responses follow Better Auth's shape, not the Claxx Auth envelope.

Password sign-in. POST /api/auth/sign-in/email with { email, password } from a client's sign-in page (the x-claxx-auth-client-slug header names the client). A client that takes no passwords answers 403. Every refusal that depends on the account answers exactly as a wrong password does, 401 { "code": "INVALID_EMAIL_OR_PASSWORD" }: an account that signs in through an identity provider (it has one connected and no password of its own; unless the service setting allowPasswordForSsoUsers is on), and an address locked after too many wrong passwords. An account without a second factor at a client that requires one is signed in, since the password was right, and the sign-in page shows how to add one; the client gets no code until the session has proved two factors. The address is compared trimmed and lower-cased, as the engine compares it. After ten password sign-ins in a row that did not succeed, password sign-in to that address is refused for fifteen minutes, with Retry-After set to the seconds the lock has left, from any network address; a successful sign-in clears the count. The number of tries and the lock time are security-policy settings: the platform's, or the stricter value of the tenant where the try happens. The count is one per address across every tenant. When the lock starts, the account with that address (if any) is emailed an unlock link: POST /api/auth/unlock with { token } from the page it opens lifts the lock, once, until the lock ends, at most three times a day per address. A browser already on record for the account has a count of its own; its lock is emailed too and its link lifts that browser's lock only. At most three lock emails go to an address in 24 hours, and the third says that a lock before a given time gets none. A completed password reset clears every count and lock of the address. An address with no account is counted and locked the same way, and every wrong-password try runs the same database statements before its answer whatever the account (server/utils/sign-in-reads.ts). An account whose address is not confirmed yet answers 403 { "code": "EMAIL_NOT_VERIFIED" } to the right password, and is sent a new confirmation link. A password typed again by a signed-in person (to change it, to delete the account, to switch two-factor on or off) is counted under the same lock: a wrong one counts as a wrong sign-in, and while the address is locked those requests answer 429 with Retry-After (the seconds left) without looking at the password.

Sign-up. POST /api/auth/sign-up/email with { email, password, name, callbackURL? } answers 200 { "token": null, "user": null, "status": true } for every well-formed request, whether or not the address already has an account. It sets one cookie, __Host-claxxauth_signup, which marks the browser that signed up, and no session. For a new address the account is made with its address unconfirmed and a confirmation link is emailed; the link (GET /api/auth/verify-email?token=..., valid 24 hours) confirms the address and sends the browser to /login?verified=true. It opens no session. The password signs nobody in until the address is confirmed. When an address is proven for the first time (by that link, an emailed sign-in link, an invitation or a password reset), every other session, every passkey and any second factor of the account are removed, and so is the password chosen at sign-up, unless the proof is the confirmation link opened in the browser whose sign-up made the account. A later sign-up for the same address changes neither the password nor which browser counts. Someone who signs another person's address up cannot use the password they chose: when the owner (or a mail scanner) opens the link, the address is confirmed and the password is gone, and the owner chooses one with "Forgot password".

Password reset request. POST /api/auth/request-password-reset with { email } answers 200 { "status": true, "message": "If this email exists in our system, check your email for the reset link" } at once, the same for every address, and looks the address up and sends the email after the answer has gone. Reset tokens and the other values the engine keeps in verifications are stored as their SHA-256 only. Choosing a password through one link (POST /api/auth/reset-password) spends every other reset, setup and sign-in link the account still has, and ends every session.

Passkey sign-in. GET /api/auth/passkey/generate-authenticate-options then POST /api/auth/passkey/verify-authentication, each with the application named as the password form names it (x-claxx-auth-client-slug). No address is sent: the options list no passkeys (allowCredentials: []), and the browser offers the person's passkeys for this host. An application with Allow passkey sign-in off gets 403 (passkey_not_allowed) for both. The challenge is single-use, lives five minutes, and is accepted only on the host that issued it (400 CHALLENGE_NOT_FOUND elsewhere). The answer is refused with 400 AUTHENTICATION_FAILED when the device did not verify the person (a PIN or a biometric), when the passkey was made for another host (or has no host on record), when the account is deleted, its address is not confirmed or it is marked to choose a new password, when the account signs in through an identity provider (connected, with no password of its own) and allowPasswordForSsoUsers is off, and when the passkey is not on record. All of those get the same bytes: status, body and headers. A password lock does not apply. A successful sign-in sets the passkey's lastUsedAt, and the session counts as two-factor.

Passkeys in the profile. All under /api/passkey, for the signed-in person, on this host only (a passkey belongs to the host it was added on). GET /api/passkey/list lists them (name, added, last used, synced) with canAdd and, when it is false, cannotAddReason. Adding: POST /api/passkey/register/options with { password }, then POST /api/passkey/register/verify with { response, password, name? }; the password is checked on both, counted like a wrong password at sign-in (401 wrong, 429 locked), the challenge is kept for this account on this host for five minutes and used once, and the device must verify the person. PATCH /api/passkey/<id> with { name } renames one (no password). POST /api/passkey/<id>/remove with { password } removes one and ends every other session the account has on this host (the requesting one stays); it answers { id, sessionsEnded }. The last one may be removed. The password asked for again is counted under the rule of the tenant whose host the request is on, and refused (403) while the account is marked to choose a new password. No attestation is asked for and none is read: whatever attestation statement an answer carries is set aside, so no certificate is checked and nothing is fetched. Another account's passkey, or one on another host, is 404. Rate-limited per address (passkey-register, and passkey-list for the list). Passkeys are not registered through the engine.

Request bodies. A request with a body to /api/auth/** or /api/passkey/** must send it as application/json, and the body must be exactly one JSON object of at most 64 KB with no byte-order mark. Anything else is refused before any check or the engine reads it: 415 (body_not_json), 413 (body_too_large) or 400 (body_not_json_object). The checks and the engine act on the same parse of the body.

Another tenant's session. A request to the engine that carries the session cookie of a session made on another tenant's host answers 401 (session_not_for_this_host): a session is read and used only on the host that made it.

The engine endpoints in use. Only these reach the sign-in engine: GET /get-session, /list-accounts, /verify-email, /reset-password/<token>, /passkey/generate-authenticate-options, /error; POST /sign-in/email, /sign-up/email, /sign-out, /request-password-reset, /reset-password, /update-user, /two-factor/enable, /two-factor/disable, /two-factor/verify-totp, /two-factor/verify-backup-code, /passkey/verify-authentication. Every other engine path answers 404, among them /verify-password, /two-factor/get-totp-uri, /two-factor/generate-backup-codes, the passkey list, delete and update endpoints, /callback/<provider>, /list-sessions, /change-email, /delete-user and the engine's own /change-password (the app's POST /api/auth/change-password is at that address and applies the password policy). rememberMe and trustDevice in a request body are ignored: every session lasts the tenant's sign-in lifetime (twelve hours unless the security policy sets less), and every sign-in of an account with a second factor asks for the code.

Two-factor. An account turns it on at /profile: POST /api/auth/two-factor/enable with the password returns a setup address (totpURI) and backup codes, and it takes effect when the first code from the authenticator app is accepted by POST /api/auth/two-factor/verify-totp. The session that does this counts as two factors from then on (it proved the password and then the new app's code); the account's other sessions do not.

An application that requires the second step, for a person with none. The password is accepted and a session made; the application gives no code for it (/api/oidc/authorize sends the browser back with reason=second_factor_setup_required). The sign-in page then shows how to add an authenticator app (or a passkey, where the application allows them) with the password just typed, using the requests above, and goes on to the application once the first code is accepted. Nothing in any answer before the password is right differs between an account with a second factor, one without, and no account.

For such an account POST /api/auth/sign-in/email answers { "twoFactorRedirect": true } and sets no session. The session is created by POST /api/auth/two-factor/verify-totp ({ "code": "123456" }) or POST /api/auth/two-factor/verify-backup-code, within ten minutes of the password step. A backup code works once.

Wrong codes at that second step are counted per account. After five in a row (a security-policy setting) the step is refused for fifteen minutes (also a setting) with 429 { "code": "TWO_FACTOR_LOCKED" } and Retry-After, from any address; a right code clears the count. Only someone who has the password reaches the step, so this cannot lock out a stranger.


Admin JSON API

Admin role required on every route. Returns the canonical envelope. CSRF enforced via session cookie. Rate-limited.

Admins need a second factor. With the security policy's adminsRequireSecondFactor on (the default), a person who is an admin here is refused every admin route until their session has proved two factors: 403 SECOND_FACTOR_SETUP_REQUIRED when the account has no second factor on this host, 403 SECOND_FACTOR_REQUIRED when it has one this session did not prove (see Error codes). The value that applies is that of the tenant whose host the request is on (a tenant can switch it on for itself, never off while the platform has it on). An application's key is not affected.

Users — /api/admin/users

MethodPathBody / QueryNotes
GET/page, pageSize≤100, searchPaginated list; filters deletedAt IS NULL
POST/{ email, name?, firstName?, lastName? }201 on create, no password and marked, a member of the host's tenant (source admin); the person is emailed a link (passwordSetupEmail) for that tenant. The address is stored trimmed and lower-cased. 409 with the existing account's info when any account holds the address as its own or as a recorded address, in any letters. The account, its address row and its membership are written together. Strict: a password or any other field is refused
GET/:id—Full user payload
PUT/:id{ email?, name?, firstName?, lastName?, emailVerified?, role?, requirePasswordReset? }Strict: any other field is refused (400). A changed address is stored trimmed and lower-cased; one another account holds (its own or a recorded address, any letters) is 409. A changed address spends every link already sent to the old one (reset, setup and sign-in links) and starts the mail counts again, in the same write as the change. requirePasswordReset: true marks the account as POST /:id/password does
DELETE/:id—Soft-deletes. Fires user.deleted before removal
POST/:id/password{}"Require a new password": in one batch, marks the account and removes everything its password could have opened or added: every session on every tenant, application tokens and unused codes, every outstanding link, every passkey, the second factor (secret, backup codes, trusted devices; switched off), every remembered browser, and every provider connected to an account that has a password. Then emails a link. Returns { sessionsEnded, passwordSetupEmail }. Whatever the account has connected. A password or generatePassword is refused
GET/:id/passkeys—Every passkey of the account on every host: { id, name, host, tenant, createdAt, lastUsedAt, synced }. No key material
DELETE/:id/passkeys/:passkeyId—Removes it and ends the account's sessions on the passkey's tenant (every tenant when no tenant has its host), forgetting the browsers there. Recorded as account.passkey.removed and auth.session.revoked
DELETE/:id/identities/:identityId—Disconnects an outside sign-in provider (a row of the user's accounts, never the password). Its provider tokens go with it, and the account's sessions on the provider's tenant end (every tenant when no tenant has the provider). Recorded, on the provider's tenant, as account.provider.unlinked and auth.session.revoked, before the answer; the owner is emailed. Returns { id, providerId, sessionsEnded }
DELETE/:id/two-factor—Switches the second factor off without marking (the lost-phone case): the secret, backup codes and trusted devices go, in one batch. 404 when the account has none. Recorded as account.two_factor.disabled (reason: admin) before the answer; the owner is emailed. Returns { id, twoFactorEnabled: false }
GET/:id/merge-previewtargetUserIdPreview entity moves
POST/:id/merge{ targetUserId, reason? }Merges source into target; records an audit log. A merge from an account marked to choose a new password leaves the target marked

Importing accounts from another system

POST /api/admin/users/import — platform admins only. Body: { clientId?, sendPasswordEmails?, users: [{ email, name?, firstName?, lastName?, emailVerified? }] }, at most 200 users per request. Send several requests for a longer list; a repeated row is answered exists and changes nothing.

  • Every imported account is created with no password and must choose one. There is no option to turn this off. Its first password sign-in on a tenant the account belongs to, whatever password is typed, gets the answer a wrong password gets, and the person is emailed a link to choose a new password (at most once every 15 minutes) that lasts the tenant's reset-link lifetime.
  • passwordHash is not accepted. A row that carries one is answered password_hash_refused and not created.
  • sendPasswordEmails: true (requires clientId) emails each account the import creates a "choose a password" link, branded for the client's tenant, on that tenant's address, valid for the tenant's reset-link lifetime. Once it has run out, "Forgot your password?" on the sign-in page sends a new one. The emails go only after every account is written.
  • An address that already has an account, as its own address or as one of its addresses, is answered exists, never modified and sent nothing. id and subject are given only when the address is the account's own or a proven one of its addresses.
  • Each account is written together with its address and its membership of the client's tenant (the platform's, with no clientId); a failure leaves none of them, stops the import, and the request fails after the accounts already written are recorded. Send it again: those are answered exists.
  • With clientId, each result includes subject: the sub claim that client will receive for the account. Store it with your own user record so that your application never has to match people by email address.

Response: { summary: { created, exists, invalid, passwordHashRefused, duplicate, passwordEmailsSent }, results: [{ email, status, id?, subject?, passwordEmail? }] }, where passwordEmail is sent, failed or skipped.

Providers — /api/admin/providers

Reading is open to the tenant's admins. Every write is for the platform admin only, signed in with a session on the platform's own host (with the tenant selected in the tenant switcher). A tenant admin and any service token get 403. Accounts are shared by every tenant and a provider decides whose account a sign-in opens, so a provider is set up by the platform admin. A tenant admin chooses which of the tenant's providers each application offers (/api/admin/clients/:id/providers).

MethodPathWhoBody / QueryNotes
GET/tenant admin—The tenant's providers
POST/platform admin{ name, slug, type, clientId, clientSecret, issuerUri?, discoveryUrl?, scopes? }201; discovery fetched for type=oidc with discoveryEnabled; secrets encrypted with AES-GCM
GET/:idtenant admin—Client secret masked
PUT/:idplatform adminpartial provider fieldsRefreshes discovery for OIDC providers
DELETE/:idplatform admin—Soft-delete: dated and switched off, so it signs no one in. Cache invalidated
POST/:id/refresh-discoveryplatform admin—Re-fetches .well-known/openid-configuration and rewrites the security policy
  • issuerUri, discoveryUrl, authorizationUrl, tokenUrl, userInfoUrl, jwksUrl and endSessionUrl must be https: addresses when given; anything else is refused with 400.
  • A discovery document gets the same rule: when its issuer, any of its endpoints or any other _endpoint or _uri address is not an https: address, the document is refused: a create or change is not saved, and a refresh keeps the document the provider had.
  • A new provider of any type has validateIdTokenSignature and requireNonce on unless the request turns signature checks off.
  • Every request to a provider is given up after five seconds. A failed discovery reports the HTTP status (and a short OAuth error code if the provider sent one), never the provider's response text.

Clients — /api/admin/clients

MethodPathBody / QueryNotes
GET/page, pageSize≤100, searchPaginated list
POST/{ name, slug, clientType?, redirectUris, postLogoutRedirectUris, allowedScopes?, themeId?, allowedProviderTokens? }201. Issues a private_key_jwt assertion keypair — private key returned only on this response
GET/:id—Excludes private key
PUT/:idpartial client fieldsIdempotent
DELETE/:id—Soft-deletes
GET/:id/providers—Providers linked to this client
POST/:id/providers{ providerId }Link a provider
DELETE/:id/providers/:providerId—Unlink a provider
POST/:id/rotate-secret—Regenerates the private_key_jwt keypair. Private PEM returned once with warning
POST/:id/revoke-user-access{ email }Signs that person out of this client on every device. Same answer, and the same work before it, whether or not the address has an account

Client fields also include emailLinkAuthEnabled (boolean, default false) and initiateLoginUri (https URL, or http on localhost, or null): see Sign-in links.

Rules on POST / and PUT /:id (each refusal is 400 VALIDATION_ERROR with a message that says what to change):

  • redirectUris and postLogoutRedirectUris: each entry follows the redirect address rule and is stored as new URL(value).href, duplicates dropped. A *, a ?, a #, a user name or password, plain http on any host but localhost, 127.0.0.1 and [::1], or any other scheme is refused.
  • An application that signs people in needs at least one postLogoutRedirectUris entry: on POST /, and on a PUT /:id that changes the type or the post-logout list.
  • slug: 2 to 63 lower-case letters, digits and hyphens, starting with a letter, on POST / and on a PUT /:id that changes it. default is kept for the platform's own tenant. Slugs are unique across all tenants, deleted clients included.
  • selfServiceSignupEnabled is false unless the request sets it, and always false while passwordAuthEnabled is false.
  • denialSupportContact: an https: or mailto: address, or null.

clientType is confidential (default) or service. public is refused on POST / and as a new type on PUT /:id; an existing public client keeps its type. The rules for service and the admin scope, enforced on POST /, PUT /:id and POST /:id/rotate-secret:

RequestWho mayOtherwise
Create a service client, or change clientType to or from serviceA platform admin signed in with a session403 PERMISSION_DENIED
Add admin to allowedScopesA platform admin signed in with a session403 PERMISSION_DENIED
admin in allowedScopes of a client that is not a service clientNobody400 VALIDATION_ERROR
Non-empty redirectUris or postLogoutRedirectUris on a service clientNobody400 VALIDATION_ERROR
Rotate the key of a service clientA platform admin signed in with a session403 PERMISSION_DENIED

A request made with an admin key (a bearer token) never counts as signed in with a session, even when the key has platform rights. A service client's passwordAuthEnabled, selfServiceSignupEnabled and emailLinkAuthEnabled are always stored false, whatever the request sends.

Admin keys

A service client with the admin scope gets an admin key from POST /api/oidc/token (grant_type=client_credentials). Sent as Authorization: Bearer <access_token> to /api/admin/**, it is accepted only when all of these hold:

  • it was issued by client_credentials (a token issued to a person is never accepted, whatever its scopes);
  • it has not expired, and its client is active, not deleted and still of type service;
  • it carries admin;
  • the request is on the address of the tenant that owns the client.

It then acts as an admin of that tenant. It has platform rights (requireAdminRole routes, every tenant) only when the client belongs to the platform's own tenant. Each request writes one admin.service_token.used audit event with client_id, and tenant_id, method, path and platform_admin in metadata.

Themes — /api/admin/themes

MethodPathBodyNotes
GET/—Unpaginated list (admin-only)
POST/theme fields — see design tokens201
GET/:id—
PUT/:idpartial theme fieldsInvalidates cached theme for every client referencing it
DELETE/:id—Fails with RESOURCE_CONFLICT if any client uses it
POST/:id/duplicate—Clones theme with name = "<name> (copy)"

Invitations — /api/admin/invitations

MethodPathBody / QueryNotes
GET/page, pageSize≤100, search, status, clientIdPaginated with client join
POST/{ email, clientId, context?, requiredProviderKeys?, ttlDays? (1-30) }201. Fires invitation.created and emails the link. Email-send failure does not fail the request
DELETE/:id—Revokes a pending invitation. Fires invitation.revoked. 400 if invitation is already accepted/revoked

context.onboardingPath, where the person goes once they accept, must be a path such as /welcome or an address on the origin of one of the client's redirect URIs. Anything else is refused with 400.

POST returns { id, email, clientId, clientSlug, expiresAt }. It adds inviteUrl, the accept link, only when the caller is a platform admin (a platform admin's session, or a service token whose client belongs to the platform). For a tenant admin the email is the only way the link travels: a tenant admin who held the link could otherwise open it for an address they do not control.

Signing Keys — /api/admin/signing-keys

MethodPathNotes
GET/Lists all keys with kid, algorithm, isActive, expiresAt, createdAt, rotatedAt
POST/generateRotates: mints a local ES256 keypair (private key stored with AES-GCM) that signs from now on, and retires the previous key gracefully. 201
POST/retireBody { "kid": "..." }. Withdraws that key at once, for a key whose private half may have leaked: it leaves the JWKS now and its tokens are refused. When it was the signing key, a new key is made first. Answers { retiredKid, newKid } (newKid is null when the key was not signing); 404 for an unknown key

Both need a signed-in platform admin; an application key is refused (403). Each is recorded as an audit event (admin.signing_key.rotated, admin.signing_key.retired).

/generate answers { kid, newKid, isActive, createdAt, ..., previousKeys: [{ kid, publishedUntil }] }: publishedUntil is when each key that was signing leaves the JWKS. A key that no longer signs keeps only its public half. A key's state is read from its row:

StateRowSignsIn JWKS, accepted here
signingisActive true, newest createdAtyesyes
retiringisActive false, rotatedAt set, expiresAt in the futurenountil expiresAt
retiredisActive false, expiresAt passed (rotation) or set to now (withdrawn)nono

Webhooks — /api/admin/webhooks

MethodPathBody / QueryNotes
GET/page, pageSize≤100, clientId?Paginated
POST/{ clientId, url, secret, events: string[], isActive? }201. secret encrypted at rest with AES-GCM
GET/:id—Excludes secret
PUT/:idpartial fieldsSupplying a new secret re-encrypts
DELETE/:id—Hard-delete
GET/:id/deliveriespage, pageSize≤100Paginated delivery log incl. statusCode, attempts, nextRetryAt, deliveredAt

Settings — /api/admin/settings

MethodPathBodyNotes
GET/—{ blockPwnedPasswords, allowPasswordForSsoUsers, defaultThemeId, securityPolicy }, the policy clamped to its bounds; never the stored row
PUT/{ blockPwnedPasswords?, allowPasswordForSsoUsers?, defaultThemeId?, securityPolicy? }At least one field required. Answers the same fields as GET

securityPolicy carries the platform's values, each a whole number within its bounds: passwordMaxFailures, passwordLockSeconds, twoFactorMaxFailures, twoFactorLockSeconds, sessionLifetimeSeconds, passwordResetLinkSeconds, auditRetentionDays and adminsRequireSecondFactor (1 on, the default, or 0 off). PUT /api/admin/tenants/:id/security-policy takes the same fields but the audit retention, each also null for "use the platform's", and refuses a value looser than the platform's (for the switch: 0 while the platform has 1).

Assets — /api/admin/assets/upload-url

MethodPathBodyNotes
POST/{ kind: 'theme_logo' | 'provider_icon' | 'theme_background', fileName, contentType, sizeBytes }Returns { uploadUrl, cdnUrl, storageKey, expiresIn: 300 }. Upload directly to uploadUrl with PUT

Email Test — /api/admin/email-test

MethodPathBodyNotes
POST/{ themeId: uuid | null, recipientEmail, previewOnly?, emailConcept?: 'password-reset' | 'welcome' | 'invitation' }With previewOnly: true returns rendered HTML/text. A send calls sendEmail, which rejects with Email sending is not configured

Provider token brokering

POST /api/provider-tokens/:provider

Mints / refreshes an upstream provider access token for the authenticated user.

Auth: Authorization: Bearer <claxx-auth-access-token>. The bearer is a Claxx Auth-issued access token from /api/oidc/token, issued on this tenant and good by the rule under POST /api/oidc/token/introspect (the sign-in it came from still live, among the rest). Anything else is 401 INVALID_TOKEN.

Body: { "requiredScopes": ["https://www.googleapis.com/auth/calendar.readonly", "..."] } (optional).

Response:

{
    "success": true,
    "data": {
        "accessToken": "<upstream-provider-token>",
        "expiresIn": 3540,
        "provider": "google",
        "scopes": ["openid", "email", "https://www.googleapis.com/auth/calendar.readonly"]
    }
}

Authorization: the calling client's allowedProviderTokens must include :provider; a per-client grant must exist; granted scopes must cover requiredScopes.

Errors:

  • INVALID_TOKEN (401) — missing or unknown bearer, or one that has stopped working: the account deleted, the client switched off or deleted, or the person signed out of the client since the sign-in
  • UNAUTHORIZED_CLIENT (403) — client not permitted for this provider
  • NO_LINKED_ACCOUNT (404) — user has no linked account for :provider
  • INSUFFICIENT_SCOPE (403) — grant exists but does not cover requiredScopes
  • REAUTH_REQUIRED (502) — upstream refresh token revoked; user must re-login
  • UPSTREAM_PROVIDER_ERROR (502) — provider returned a transient failure

Responses always set Cache-Control: no-store, private.

See the provider token brokering guide for end-to-end integration patterns.


Operations

GET /api/health

Liveness + dependency check. Returns HTTP 200 when healthy, 503 otherwise.

{
    "status": "healthy",
    "checks": {
        "database": { "status": "ok", "latency": 12 },
        "cache": { "status": "ok", "latency": 2 }
    },
    "timestamp": "2026-04-17T10:30:00.000Z"
}

Cache status can be ok, degraded, or warming. warming does not flip healthy false.


Conventions

  • Pagination — page (≥1) and pageSize (≤100). Response meta.pagination = { page, pageSize, total, totalPages }.
  • Timestamps — ISO-8601 UTC with Z suffix. Server uses nowUTC() throughout.
  • IDs — UUID v4 unless otherwise stated. URL params are parsed via getRouterParam.
  • Secrets in responses — returned exactly once (client clientAssertionPrivateKey, upload presigns). Never logged; never re-fetchable.
  • Cache headers — token and provider-token endpoints set Cache-Control: no-store. Other endpoints use defaults.
  • Request IDs — every response carries this service's id for the request in the X-Request-Id header, and every error body carries the same id as requestId. The id is always one the service made (req_ and 24 hex digits); log it from the response to line your logs up with ours. An X-Request-Id you send is not used as the request id. When it is up to 64 letters, digits, ., _ or -, it is written beside ours in the request log line, and nowhere else.
  • CORS — only /.well-known/** and /api/oidc/jwks allow cross-origin reads. Every other route sends no CORS headers, so a browser page on another origin cannot read it. An application calls token, userinfo, session/check and the rest from its own server.
  • Requests that change something — a POST, PUT, PATCH or DELETE to /api/** must come from a page on this host (its Origin header is this host) or from a server (no Origin header and no cookies). Anything else is answered 403 with data.code = "origin_not_allowed". A script that calls the API with a session cookie has to send Origin too.

On this page

  • Response envelopes
  • Success
  • Error
  • Authentication
  • OIDC endpoints
  • GET /.well-known/openid-configuration
  • GET /api/oidc/authorize
  • POST /api/oidc/token
  • POST /api/oidc/token/introspect
  • POST /api/oidc/token/revoke
  • POST /api/oidc/sign-in-link
  • POST /api/oidc/session/revoke
  • POST /api/oidc/session/check
  • GET / POST /api/oidc/userinfo
  • GET /api/oidc/jwks
  • GET /api/oidc/end-session
  • Provider sign-in routes
  • GET /oauth2/login
  • GET/POST /oauth2/callback
  • Auth JSON API
  • POST /api/auth/link-provider
  • GET /api/auth/providers
  • GET /api/auth/client-policy
  • GET /api/auth/invitation-context
  • GET /api/auth/theme
  • GET /api/auth/linkable-providers
  • GET /api/auth/security-state
  • Changing a second factor, once the account has one
  • GET /api/auth/second-factor/status
  • POST /api/auth/second-factor/verify
  • POST /api/auth/second-factor/passkey/options and /verify
  • GET /api/auth/sessions
  • POST /api/auth/sessions/end and /end-others
  • POST /api/auth/session-context
  • POST /api/auth/delete-account
  • POST /api/auth/change-password
  • POST /api/auth/email-link/request
  • POST /api/auth/email-link/consume
  • POST /api/auth/accept-invite
  • ALL /api/auth/[...all]
  • Admin JSON API
  • Users — /api/admin/users
  • Providers — /api/admin/providers
  • Clients — /api/admin/clients
  • Admin keys
  • Themes — /api/admin/themes
  • Invitations — /api/admin/invitations
  • Signing Keys — /api/admin/signing-keys
  • Webhooks — /api/admin/webhooks
  • Settings — /api/admin/settings
  • Assets — /api/admin/assets/upload-url
  • Email Test — /api/admin/email-test
  • Provider token brokering
  • POST /api/provider-tokens/:provider
  • Operations
  • GET /api/health
  • Conventions
DocsPrivacyTerms
© 2026 Claxx Digital Group