session cookie. Rather than long-lived API keys, each login or registration creates a new session. Write operations — any POST, PATCH, or DELETE — additionally require a short-lived CSRF token to prevent cross-site request forgery. This two-layer approach means your credentials never travel in a header or URL, and every sensitive action is explicitly authorized.
How Authentication Works
When you log in or register, the server issues an HttpOnlysession cookie with SameSite=Lax. Because the cookie is HttpOnly, JavaScript running in the browser cannot read it — only the browser itself forwards it automatically on same-origin requests. The SameSite=Lax policy prevents the cookie from being sent on cross-site subresource requests while still allowing top-level navigations.
Key properties of the session cookie:
- HttpOnly — not accessible via
document.cookie; protects against XSS token theft - SameSite=Lax — sent on same-site requests and top-level cross-site navigations, blocked on cross-site subrequests
- Opaque — the cookie value is a random token; the server looks up the session record in the database on every request
- Revocable — call
DELETE /auth/session(current session) orDELETE /auth/sessions/{id}(any session) to invalidate immediately
401 Unauthorized.
Getting a Session
CallPOST /auth/login with your email and password to authenticate. On success the server sets the session cookie and returns your public_id and email_verified status.
200 OK):
POST /auth/register with the same fields plus first_name, last_name, and phone_number (E.164 format). Registration also sets the session cookie and queues a 24-hour verification email.
CSRF Protection
Every state-changing request — anyPOST, PATCH, or DELETE — must include a valid CSRF token in the x-csrf-token header. The token is bound to your current session, so you must have an active session before fetching one.
Step 1 — Fetch a token:
200 OK):
x-csrf-token header value (double-submit cookie pattern). A missing or mismatched token returns 403 Forbidden.
Session Management
The API gives you full visibility and control over all active sessions for your account.
Each session entry in the list includes a
public_id (prefixed ses_), device and IP metadata, created_at, and expires_at timestamps in ISO 8601 UTC.
List all active sessions:
Revoking your current session via
DELETE /auth/sessions/{id} clears the session cookie immediately — the same effect as calling DELETE /auth/session. Revoking another session (e.g., from a different device) does not affect your current session or cookie.