Backend API Authentication
Overview of authentication mechanisms for the Wacht Platform Backend API.Authentication Methods
The Wacht Platform Backend API supports multiple authentication methods:| Method | Use Case | Description |
|---|---|---|
| API Keys | Server-to-server | Bearer token authentication |
| JWT Tokens | User sessions | Generated after signin/signup |
API Key Authentication
Use API keys for backend-to-backend communication.Getting an API Key
- Navigate to wacht.dev
- Go to your deployment settings
- Navigate to API Keys
- Click Generate New Key
- Copy the key (starts with
sk_test_orsk_live_)
Using API Keys
Include the API key in the Authorization header:cURL Example
Security Best Practices
- ✅ Store in environment variables
- ✅ Use different keys for dev/staging/production
- ✅ Rotate keys regularly
- ❌ Never commit to git
- ❌ Never expose in client-side code
JWT Token Authentication
After users authenticate, they receive a JWT token for subsequent requests.Token Structure
Using JWT Tokens
Error Handling
Common Authentication Errors
| Error | Description | Solution |
|---|---|---|
UNAUTHORIZED | Invalid API key | Check your API key |
TOKEN_EXPIRED | JWT token expired | Implement token refresh |
MISSING_DEPLOYMENT_ID | No deployment ID | Include X-Deployment-ID header |
Next Steps
- Backend API Overview - Complete API guide
- Getting Started - Quickstart guide
- Rust SDK Installation - SDK setup
