Learn how to authenticate your requests to the MailCub API securely and efficiently.
Navigate to your account dashboard at dashboard.mailcub.com
Click on "Settings" in the sidebar, then select "API Keys"
Click "Create New Key", give it a name, and set appropriate permissions
Copy the API key immediately - you won't be able to see it again
sk_live_••••••••••••••••••••••••••••••••••••
Live keys start with sk_live_
Test keys start with sk_test_
Most common method using API keys in the Authorization header
Authorization: Bearer sk_live_1234567890abcdef
Alternative method using username/password authentication
Authorization: Basic base64(api_key:password)
curl -X POST https://api.mailcub.com/v1/send \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"to": "user@example.com", "subject": "Test"}'
const response = await fetch('https://api.mailcub.com/v1/send', { method: 'POST', headers: { 'Authorization': 'Bearer ' + process.env.MAILCUB_API_KEY, 'Content-Type': 'application/json' }, body: JSON.stringify({ to: 'user@example.com', subject: 'Test Email' }) });
import requests import os headers = { 'Authorization': f'Bearer {os.getenv("MAILCUB_API_KEY")}', 'Content-Type': 'application/json' } response = requests.post( 'https://api.mailcub.com/v1/send', headers=headers, json={'to': 'user@example.com', 'subject': 'Test Email'} )
Never hard-code API keys in your source code. Use environment variables or secure key management systems.
Create separate API keys for development, staging, and production environments.
Regularly rotate your API keys and revoke unused keys to maintain security.
Keep track of API key usage and set up alerts for unusual activity.
This error occurs when your API key is missing, invalid, or expired.
{ "error": { "code": "unauthorized", "message": "Invalid API key provided" } }
Your API key doesn't have permission to perform this action.
{ "error": { "code": "forbidden", "message": "API key lacks required permissions" } }
Free Plan: 100 requests per hour
Starter Plan: 1,000 requests per hour
Professional Plan: 10,000 requests per hour
Enterprise Plan: Custom limits
Tip: Check the X-RateLimit-Remaining
header in API responses to monitor your usage.
Use this simple test to verify your API key is working correctly:
curl -X GET https://api.mailcub.com/v1/account \ -H "Authorization: Bearer YOUR_API_KEY"