Overview
All API requests (except public endpoints) require a valid JWT token in theAuthorization header:
Token flow
Getting a token
Mobile (React Native)
Web (Next.js)
Token lifecycle
Backend verification
The API verifies tokens using Clerk’s secret key:Error responses
401 Unauthorized
Missing or invalid token:403 Forbidden
Valid token but insufficient permissions:Public endpoints
These endpoints don’t require authentication:Testing authentication
Get a token
Test API request
Security best practices
- Never expose tokens - Don’t log or store tokens insecurely
- Use HTTPS - Always use HTTPS in production
- Short expiration - Tokens expire after 1 hour
- Secure storage - Use SecureStore (mobile) or HTTP-only cookies (web)
- Revocable sessions - Sessions can be revoked from Clerk Dashboard
Troubleshooting
Token not being sent
Token not being sent
Check that your HTTP client is including the Authorization header:
401 on every request
401 on every request
- Verify Clerk secret key matches between frontend and backend
- Check token hasn’t expired
- Ensure user is signed in
Token refresh failing
Token refresh failing
- Check network connectivity
- Verify Clerk session is valid
- Try signing out and back in