Overview
The Adapt API uses bearer token authentication. All requests to/v1/* endpoints (except /v1/auth/*) require a valid authentication token in the Authorization header.
Authentication Methods
Adapt supports two authentication methods:JWT Bearer Tokens (Primary)
JSON Web Tokens (JWTs) are issued by Supabase Auth and used by web applications. These tokens have short expiry times and can be refreshed. Usage:- Short expiry (typically 15 minutes)
- Issued during user login via Supabase Auth
- Automatically refreshed by the client
- Contains user claims and metadata
API Keys (For Integrations)
API key management endpoints are planned but not yet implemented. Currently, only JWT authentication is supported.
- Long-lived (no automatic expiry)
- Scoped permissions (e.g.,
jobs:read,jobs:create) - Managed through user dashboard
- Suitable for server-to-server communication
Making Authenticated Requests
Include your token in theAuthorization header using the Bearer scheme:
Authentication Flow
Web Application Flow
- User signs in via Supabase Auth (email/password or OAuth)
- Supabase returns a JWT access token and refresh token
- Client includes JWT in
Authorizationheader for API requests - Client refreshes token before expiry using refresh token
User Registration
New users are automatically created in Adapt’s database upon first authentication:The user ID from your authentication provider (Supabase).
The user’s email address.
The user’s first name (max 80 characters).
The user’s last name (max 80 characters).
The user’s full name (max 120 characters).
Custom organisation name. If not provided, defaults to the email domain or “Personal Organisation”.
User Profile
Retrieve the authenticated user’s profile:Update Profile
Update the authenticated user’s profile information:Update first name (max 80 characters).
Update last name (max 80 characters).
Update full name (max 120 characters).
Session Validation
Validate a JWT token and retrieve session information:Protected vs Public Endpoints
Public Endpoints (No Authentication Required)
GET /health- Service health checkGET /health/db- Database health checkPOST /v1/auth/register- User registrationPOST /v1/auth/session- Session validation
Protected Endpoints (Authentication Required)
All other/v1/* endpoints require authentication:
/v1/jobs- Job management/v1/schedulers- Recurring job schedulers/v1/auth/profile- User profile- Future endpoints for tasks, webhooks, API keys, etc.
Authentication Errors
The API returns specific error codes for authentication failures:Missing Authentication
Invalid Token
Insufficient Permissions
Security Best Practices
Token Storage
- Web applications: Store tokens in memory or
httpOnlycookies - Mobile apps: Use secure keychain/keystore mechanisms
- Server applications: Use environment variables or secret management systems
Token Refresh
- Implement automatic token refresh before expiry
- Handle
401 Unauthorizedresponses by refreshing and retrying - Redirect to login if refresh fails
Secure Communication
- Always use HTTPS in production
- Validate SSL/TLS certificates
- Never send tokens in URL query parameters
Organisation-Based Access
All API resources are scoped to the authenticated user’s organisation. Users can only access resources that belong to their organisation, enforced by:- Database-level Row Level Security (RLS)
- Application-level organisation ID filtering
- JWT claims containing organisation context