A Auth API docs

Integrate

Authentication

The core flow is the same for every client: register, verify the email, log in, keep the token pair fresh, log out.

Register

curl -sX POST http://localhost:8080/register \
  -H "X-App-ID: $APP" -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","password":"Str0ng!Passw0rd"}'
  • 201 — {"message":"User registered successfully. Please check your email for verification."}
  • The password is validated against the application's policy (pw_min_length, pw_require_*, pw_history_count).
  • A verification email is sent. Without SMTP the API logs the message instead (development fallback) and the account stays unverified.

Verify the email

The verification link contains a token; your frontend forwards it to:

curl -s "http://localhost:8080/verify-email?token=$TOKEN" -H "X-App-ID: $APP"

Resend with POST /resend-verification and {"email":"user@example.com"}.

Log in

curl -sX POST http://localhost:8080/login \
  -H "X-App-ID: $APP" -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","password":"Str0ng!Passw0rd"}'

Successful response:

{
  "access_token": "eyJhbGciOi…",
  "refresh_token": "eyJhbGciOi…"
}

2FA challenge response:

{
  "requires_2fa": true,
  "message": "2FA verification required",
  "temp_token": "5daf6d7f-…",
  "method": "totp",
  "sms_recovery_available": true
}

Submit the second factor to POST /2fa/login-verify.

StatusMeaning
400Invalid body, or CAPTCHA required
401Wrong email or password
403Email not verified
423Account locked by brute-force protection
429Rate limited

If the application enforces password rotation, a login with an expired password returns password_expired: true and no tokens; send the user through the reset flow.

Refresh and rotate

curl -sX POST http://localhost:8080/refresh-token \
  -H "X-App-ID: $APP" -H "Content-Type: application/json" \
  -d '{"refresh_token":"'$REFRESH_TOKEN'"}'

Each call returns a new pair and invalidates the old refresh token. Reusing a rotated token is rejected — treat that as a signal to log the user out.

Log out

curl -sX POST http://localhost:8080/logout \
  -H "X-App-ID: $APP" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"access_token":"'$ACCESS_TOKEN'","refresh_token":"'$REFRESH_TOKEN'"}'

The access token is blacklisted in Redis for its remaining lifetime and the session is removed. With session groups enabled the user may also be logged out of peer apps.

Profile and password

EndpointPermissionPurpose
GET /profileuser:readCurrent user
PUT /profileuser:writeName, locale, picture
PUT /profile/emailuser:writeChange email (re-verification required)
PUT /profile/passworduser:writeChange password (current password required)
POST /profile/set-passworduser:writeSet a password on a social-only account
DELETE /profileuser:deleteDelete the account
GET /auth/validate—Validate the current access token

Password changes invalidate other sessions and blacklist outstanding access tokens.

Forgot and reset

curl -sX POST http://localhost:8080/forgot-password \
  -H "X-App-ID: $APP" -H "Content-Type: application/json" \
  -d '{"email":"user@example.com"}'

curl -sX POST http://localhost:8080/reset-password \
  -H "X-App-ID: $APP" -H "Content-Type: application/json" \
  -d '{"token":"'$RESET_TOKEN'","new_password":"N3w!Passw0rd"}'

forgot-password always returns the same response, whether or not the email exists.

curl -sX POST http://localhost:8080/magic-link/request \
  -H "X-App-ID: $APP" -H "Content-Type: application/json" \
  -d '{"email":"user@example.com"}'

curl -sX POST http://localhost:8080/magic-link/verify \
  -H "X-App-ID: $APP" -H "Content-Type: application/json" \
  -d '{"token":"'$TOKEN'"}'

The link is single-use and expires. verify accepts an optional app_id in the body for multi-application frontends.

Social login

StepEndpoint
Start`GET /auth/{google\facebook\github}/login?redirect_uri=…`
Callbackprovider → GET /auth/{provider}/callback (handled server-side, then redirected)
Link to an existing accountGET /auth/{provider}/link (JWT) → callback
Confirm an account mergePOST /auth/merge/confirm with the merge_token and the existing password

OAuth state is HMAC-signed, single-use and bound to the initiating browser with an HttpOnly cookie. Cross-site frontends must start the flow with credentials included:

window.location = `${API}/auth/google/login?redirect_uri=${encodeURIComponent(callback)}`;

The API sets the binding cookie and redirects to Google.

Passkeys (passwordless)

StepEndpoint
BeginPOST /passkey/login/begin
FinishPOST /passkey/login/finish
Register a passkeyPOST /passkey/register/begin → POST /passkey/register/finish (JWT)
ManageGET /passkeys, PUT /passkeys/:id, DELETE /passkeys/:id

The begin/finish dance speaks WebAuthn JSON; the browser's navigator.credentials.create() / .get() payloads are passed through as-is.