Authentication
Learn how to authenticate your requests to the ChurnShield API.
API Keys
All requests to the ChurnShield API must include an API key in the Authorization header. API keys carry many privileges, so be sure to keep them secure.
How to create a new API key:
- Navigate to Settings → API Keys
- Click "Generate New API Key"
- Give your key a descriptive name (e.g., "Production" or "Development")
- Copy your new API key immediately - you won't be able to see it again!
Authorization: Bearer YOUR_API_KEY
Making Authenticated Requests
Here's how to make authenticated requests using different programming languages:
curl https://api.churnshield.ai/api/customers \
-H "Authorization: Bearer YOUR_API_KEY"
API Key Best Practices
Keep Keys Secure
Never share your API keys in publicly accessible areas such as GitHub, client-side code, or forums.
Use Environment Variables
Store your API keys in environment variables or a secure configuration management system.
Rotate Keys Regularly
Periodically generate new API keys and update your applications to maintain security. You can create and revoke keys in your API Keys Settings.
Use Different Keys for Different Environments
Use separate API keys for development, staging, and production environments.
Authentication Errors
If authentication fails, the API will return a 401 Unauthorized response:
{
"error": {
"code": "invalid_auth",
"message": "Invalid API key provided",
"status": 401
}
}
Common authentication errors:
- Missing API key in the Authorization header
- Invalid or expired API key
- API key does not have permission for the requested action