Every protected Surqo endpoint expects a Supabase-issued JWT signed with the ES256 algorithm (P-256 curve). Pass the token in the standardDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ricardomb-tech/surqo/llms.txt
Use this file to discover all available pages before exploring further.
Authorization: Bearer <token> header. The backend validates the JWT against Supabase’s public JWKS endpoint, extracts the sub claim as the user’s UUID, and — on the very first valid request — automatically creates a UserProfile with plan = "free" and analyses_used = 0. There is no separate registration step.
Auth Flow
Obtaining a JWT Token
- Frontend (TypeScript)
- Backend / CLI (curl)
The Surqo frontend uses For subsequent requests the frontend uses
@supabase/ssr. Call signInWithPassword and read data.session.access_token.getAccessToken() from lib/auth.ts, which calls supabase.auth.getSession() and returns the access token from the active session — automatically refreshing it when close to expiry.Using the Token
Pass the JWT in theAuthorization header on every authenticated request.
401 Unauthorized if the header is missing, malformed, or the token has expired.
JWT Validation Details
The following describes how the FastAPI backend validates incoming tokens — relevant for backend integrators, custom tooling, and debugging auth issues.JWKS lookup (primary path)
The backend fetches the Supabase public key set from:The response is cached in-process for 1 hour (TTL = 3 600 s), re-fetched on the next request after expiry. This means the public key is loaded at most once per hour — not on every request.
HS256 secret fallback (legacy)
If
SUPABASE_JWT_SECRET is set in the environment, the backend attempts HS256 verification as a secondary fallback. This supports older Supabase project configurations that issued HS256 tokens.| Property | Value |
|---|---|
| Algorithm | ES256 (P-256 curve) |
| Expected audience | authenticated |
| User identifier claim | sub (UUID, matches user_profiles.user_id) |
| Key source | Supabase JWKS endpoint /auth/v1/.well-known/jwks.json |
| Key cache duration | 1 hour (in-process) |
Rate limiting also uses the JWT
sub claim when a token is present, ensuring that an authenticated user cannot evade per-user limits by rotating IP addresses. The signature is not re-verified for rate-limit keying — only for actual authorization.Auto-Profile Creation
The first authenticated request to any protected endpoint triggers automatic profile provisioning. No explicit registration call is required.Subsequent requests simply look up the existing profile. The creation is transparent — your client code does not need to handle it.
| Field | Default |
|---|---|
plan | free |
analyses_used | 0 |
tokens_used | 0 |
email_alerts_this_month | 0 |
WebSocket Authentication
WebSocket connections cannot carry custom headers in most browser environments. Pass the JWT as a query parameter namedtoken instead.
Plan-Gated Endpoints
Certain endpoints enforce free-tier quotas. When a quota is exhausted the API responds with402 Payment Required and a structured error body — never a generic error string.
GET /api/v1/users/me/plan-limits at any time to inspect remaining allowances before making quota-consuming requests: