/api/auth/v1
Register User
Register a new user with email and password.POST /api/auth/v1/register
Request Body
User’s email address (will be normalized to lowercase)
User’s password (must meet password policy requirements)
Password confirmation (must match password)
Response
Success redirect to login page with confirmation message
Invalid password, redirects back to registration
Password authentication is disabled
Failed to send verification email
If a user with the email already exists, TrailBase returns success to prevent email enumeration attacks.
Login
Authenticate users with email and password.POST /api/auth/v1/login
Request Body
User’s email address
User’s password
Optional redirect URL after successful login (for web flows)
Set to
"code" to use Authorization Code Flow with PKCEPKCE code challenge (required when using Authorization Code Flow)
Response (JSON)
Short-lived JWT authentication token (default: 60 minutes)
Long-lived refresh token (default: 30 days)
CSRF token for state-changing operations
Response (Form/Cookie)
For form submissions, setsauth_token and refresh_token cookies and redirects.
Authorization Code Flow with PKCE
For native/mobile apps that cannot securely store tokens:Refresh Token
Obtain a new auth token using a refresh token.POST /api/auth/v1/refresh
Request Body
Valid refresh token from login response
Response
New short-lived JWT authentication token
New CSRF token
Refresh tokens are single-use. Each refresh returns a new auth token and the refresh token is rotated.
Logout
Log out the current user and delete their session(s).Logout (GET) - All Sessions
GET /api/auth/v1/logout
Optional URL to redirect to after logout
Logout (POST) - Specific Session
POST /api/auth/v1/logout
Refresh token for the specific session to delete
Login Status
Check current authentication status.GET /api/auth/v1/status
Response
Exchange Authorization Code
Exchange authorization code for auth tokens (OAuth-style flow).POST /api/auth/v1/token
Request Body
Authorization code received from redirect (24 characters)
PKCE code verifier matching the challenge from login request
Response
Authorization codes are single-use and expire after 5 minutes.
OAuth Integration
List OAuth Providers
Get configured OAuth providers.GET /api/auth/v1/oauth/providers
Response
OAuth Login
Initiate OAuth login flow with external provider.GET /api/auth/v1/oauth/{provider}/login
OAuth provider name (google, github, microsoft, discord, etc.)
Callback URL after successful authentication
Set to
"code" for Authorization Code FlowPKCE code challenge for Authorization Code Flow
OAuth Callback
Handles the callback from OAuth provider.GET /api/auth/v1/oauth/{provider}/callback
Authorization code from OAuth provider
CSRF state token for validation
Email Verification
Request Email Verification
GET /api/auth/v1/verify_email/trigger
Verify Email
GET /api/auth/v1/verify_email/confirm/{code}
Password Management
Change Password
POST /api/auth/v1/change_password
Request Password Reset
POST /api/auth/v1/reset_password/request
Reset Password
POST /api/auth/v1/reset_password/update
User Management
Delete User Account
DELETE /api/auth/v1/delete
Avatar Management
Get User Avatar
GET /api/auth/v1/avatar/{user_id}
Upload Avatar
POST /api/auth/v1/avatar
Delete Avatar
DELETE /api/auth/v1/avatar
Error Responses
Invalid credentials, expired token, or authentication required
Password authentication disabled or email not verified
User already exists (only in debug mode)
Rate limit exceeded (password reset, email verification)
Password Policy
Password requirements can be configured via TrailBase settings. Default policy:- Minimum length: 8 characters
- Must contain uppercase, lowercase, digit, and special character
- Cannot be a common password
Token Lifetimes
- Auth Token: 60 minutes (configurable, 2 minutes in debug mode)
- Refresh Token: 30 days (configurable)
- Authorization Code: 5 minutes
- Email Verification Code: Varies by configuration
- Password Reset Code: Varies by configuration