Overview
Sorcia uses JWT-based authentication powered by Supabase Auth. All API requests require a valid access token in the Authorization header.Authentication Flow: Sign up/Login → Email Verification → Access Token → API Requests
Authentication Methods
Sorcia supports multiple authentication methods:Email & Password
Traditional email/password authentication
Magic Link
Passwordless login via email
OAuth
Google, GitHub, Microsoft (Enterprise)
API Keys
Server-to-server authentication
Sign Up
Create a new user account and organization.Request Body
User’s email address
Password (minimum 6 characters)
Name of the organization to create
Response
Login
Authenticate with email and password to receive an access token.Request Body
User’s email address
User’s password
Response
JWT access token (valid for 1 hour)
Refresh token for obtaining new access tokens
Token expiration time in seconds
Magic Link
Request a passwordless login link sent via email.Response
Refresh Token
Exchange a refresh token for a new access token.Response
Making Authenticated Requests
Include the access token in theAuthorization header for all API requests:
API Keys (Server-to-Server)
For server-to-server integrations, use API keys instead of user tokens.Generate API Key
- Navigate to Settings → API Keys
- Click Create API Key
- Name your key (e.g., “Production Server”)
- Copy the key immediately (it won’t be shown again)
Using API Keys
Include the API key in theX-API-Key header:
Rotate API Keys
Regularly rotate API keys for security:- Generate a new API key
- Update your applications to use the new key
- Delete the old key once migration is complete
Error Responses
Unauthorized (401)
- Verify token is included in header
- Check token hasn’t expired
- Refresh token if needed
Forbidden (403)
- Verify user has required role
- Check organization membership
- Contact admin for access
Rate Limited (429)
- Implement exponential backoff
- Reduce request frequency
- Upgrade plan for higher limits
Rate Limits
API rate limits vary by plan:| Plan | Requests/Minute | Burst Limit |
|---|---|---|
| Free | 10 | 20 |
| Pro | 100 | 200 |
| Enterprise | 1000 | 2000 |
Best Practices
Store Tokens Securely
Store Tokens Securely
- Never store tokens in localStorage (XSS vulnerable)
- Use httpOnly cookies for web apps
- Use secure storage (Keychain/Keystore) for mobile apps
- Encrypt tokens at rest in databases
Handle Token Expiration
Handle Token Expiration
- Implement automatic token refresh
- Handle 401 errors gracefully
- Show re-login prompt when refresh fails
Use HTTPS Only
Use HTTPS Only
- Never send tokens over HTTP
- Enable HSTS in production
- Pin certificates for mobile apps
Implement Logout
Implement Logout
- Clear tokens on logout
- Revoke refresh tokens server-side
- Clear all session data