API Authentication
Secure access to the AuthentiVoice API using JWT tokens and API keys.Overview
AuthentiVoice uses a dual authentication system:- JWT Tokens: For user-specific operations and frontend authentication
- API Keys: For server-to-server communication and integrations
All API requests must include authentication credentials in the request headers.
Authentication Methods
JWT Token Authentication
1
Obtain Token
Authenticate via Supabase Auth to receive a JWT token
2
Include in Headers
Add the token to the Authorization header
3
Handle Expiration
Refresh tokens before they expire (typically 1 hour)
API Key Authentication
For server-to-server communication:Obtaining Credentials
JWT Tokens via Supabase
API Key Generation
1
Navigate to API Settings
Go to Settings → API → Keys in the dashboard
2
Create New Key
Click “Generate New Key” and configure:
- Key name for identification
- Expiration date (optional)
- Permission scopes
3
Save Key Securely
Copy the key immediately - it won’t be shown again
Permission Scopes
Available Scopes
Scope Combinations
Common permission sets:Read-Only Access
read:analyses, read:reviewsReviewer Access
read:analyses, read:reviews, write:reviewsFull Access
All scopes enabled
Integration Access
write:analyses, read:analysesSecurity Headers
Required Headers
All authenticated requests must include:Optional Security Headers
Token Management
Token Refresh
JWT tokens expire after 1 hour. Implement automatic refresh:API Key Rotation
Best practices for API key management:1
Regular Rotation
Rotate keys every 90 days
2
Multiple Keys
Maintain 2 active keys during rotation
3
Gradual Migration
Update integrations before revoking old keys
4
Audit Usage
Monitor key usage in audit logs
Error Responses
Authentication Errors
Error Response Format:Rate Limiting
Default Limits
Rate Limit Headers
Monitor your usage with response headers:Security Best Practices
Token Security
Token Security
- Never store tokens in localStorage (use secure cookies)
- Implement token refresh before expiration
- Clear tokens on logout
- Use HTTPS for all API calls
API Key Security
API Key Security
- Store keys in environment variables
- Never commit keys to version control
- Use different keys for different environments
- Implement key rotation schedule
Request Security
Request Security
- Validate SSL certificates
- Implement request signing for sensitive operations
- Use request IDs for tracking
- Log authentication failures
Integration Security
Integration Security
- Whitelist IP addresses when possible
- Use webhook signatures
- Implement retry with backoff
- Monitor for unusual patterns
Testing Authentication
cURL Examples
Next Steps
1
Generate Credentials
Create your first API key or obtain JWT token
2
Test Authentication
Verify your credentials work with a simple GET request
3
Implement Token Refresh
Set up automatic token refresh in your application
4
Monitor Usage
Track your API usage and rate limits