Authorization Header
Include the token in theAuthorization header:
Obtaining a Token
Tokens are obtained through the AWS Cognito authentication flow:- Sign up — Create an account with email and password via the Cognito Hosted UI or SDK
- Sign in — Authenticate to receive an access token, ID token, and refresh token
- Use the access token — Pass it in the
Authorizationheader for API requests - Refresh — When the access token expires, use the refresh token to get a new one
Token Lifecycle
| Token | Lifetime | Purpose |
|---|---|---|
| Access Token | 1 hour | API authentication |
| ID Token | 1 hour | User identity claims |
| Refresh Token | 30 days | Obtain new access/ID tokens |
Authentication Errors
| Status | Meaning |
|---|---|
401 Unauthorized | Token is missing, expired, or invalid |
403 Forbidden | Token is valid but user lacks permission (wrong plan, disabled account, not admin) |
401 Response
403 Response (Plan Gate)
403 Response (Disabled Account)
Middleware Chain
The API applies middleware in this order:- requireAuth — Validates the JWT, extracts user identity, creates user record on first login
- requirePlan(‘pro’) — (Pro-gated endpoints only) Checks the user’s subscription plan
- requireAdmin — (Admin endpoints only) Checks the
is_adminflag - activityLogger — Logs the request to the activity_logs table