All Send.dev API requests require authentication using an API key. This page covers how to obtain and use API keys securely.
API Key Types
Send.dev provides two types of API keys:
| Type | Prefix | Usage |
|---|---|---|
| Live | sk_live_ | Production environment |
| Test | sk_test_ | Testing and development |
Test Mode
Test mode API keys work identically to live keys, but emails are validated without being sent. Use test mode to develop and debug your integration without consuming your quota.
Using Your API Key
Include your API key in the Authorization header of every request:
curl https://api.send.dev/v1/emails \
-H "Authorization: Bearer sk_live_your_api_key"Header Format
Authorization: Bearer <your_api_key>Never Expose API Keys
Never include API keys in client-side code, URLs, or public repositories. API keys should only be used server-side.
Creating API Keys
- Log in to your Send.dev Dashboard
- Navigate to Settings → API Keys
- Click Create API Key
- Optionally, add a description (e.g., "Production server", "CI/CD pipeline")
- Click Create
Copy Your Key
Your API key is only shown once at creation. Copy it immediately and store it securely.
Domain Restrictions
API keys can be scoped to specific sending domains for added security:
- When creating an API key, select Restrict to domains
- Choose which verified domains this key can send from
- Any send attempt from an unauthorized domain will fail with a
403 Forbiddenerror
This is useful for:
- Limiting blast radius if a key is compromised
- Giving different teams access to different domains
- Separating production and staging environments
Revoking API Keys
If an API key is compromised or no longer needed:
- Go to Settings → API Keys
- Find the key you want to revoke
- Click the Revoke button
- Confirm the revocation
Immediate Effect
Revoking a key takes effect immediately. Any requests using that key will fail.
Authentication Errors
| Status Code | Error | Description |
|---|---|---|
401 | unauthorized | Missing or invalid API key |
403 | forbidden | Valid key, but lacks permission for this action |
429 | rate_limited | Too many requests—slow down |
Example Error Response
{
"error": {
"code": "unauthorized",
"message": "Invalid API key provided",
"docs_url": "https://send.dev/docs/authentication"
}
}Best Practices
- Use environment variables - Never hardcode API keys
- Rotate regularly - Create new keys periodically and revoke old ones
- Scope keys - Use domain restrictions when possible
- Monitor usage - Check the dashboard for unusual activity
- Use test keys for development - Avoid using live keys in development environments
- Separate keys per environment - Use different keys for staging and production
Environment Variables Example
# .env file (never commit this!)
SEND_API_KEY=sk_live_your_api_key_here// Node.js
const apiKey = process.env.SEND_API_KEY;
if (!apiKey) {
throw new Error('SEND_API_KEY environment variable is required');
}Next Steps
- API Keys - Detailed API key management
- Rate Limits - Understand request limits
- Error Handling - Handle errors gracefully