Troubleshooting Authentication
Fix issues with API keys and authentication.Common Errors
401 Unauthorized
Error:Missing API Key
Missing API Key
Ensure you’re including the Authorization header:
Invalid Key Format
Invalid Key Format
API keys must start with
le_ or le_test_. Check for typos or extra spaces.Revoked Key
Revoked Key
The key may have been deleted. Create a new one in the dashboard.
Environment Mismatch
Environment Mismatch
Test keys (
le_test_) only work in test mode. Use production keys for live sending.403 Forbidden
Error:IP Restriction Errors
Error:- Check your API key’s IP restrictions in the dashboard
- Add your current IP or remove restrictions:
Verifying Your API Key
Test your key with a simple request:SDK Authentication
Node.js
PHP
Environment Variables
Store keys in environment variables:Key Security Best Practices
Never commit keys to git
Never commit keys to git
Add
.env to your .gitignore file.Use environment-specific keys
Use environment-specific keys
Separate keys for development, staging, and production.
Rotate keys regularly
Rotate keys regularly
Create new keys and retire old ones every 90 days.
Use minimum permissions
Use minimum permissions
Only grant permissions that are actually needed.