API Documentation
Everything you need to send emails via our REST API
Quick Start
- Create an account
- Create an API key with your SMTP credentials in the Dashboard
- Copy the API key (starts with
rk_) - shown only once! - Make HTTP POST requests to send emails
Base URL: https://2smtp.com
How It Works
You send HTTP request
POST to our API with your email data
We relay via YOUR SMTP
Using the credentials you configured
Email is delivered
Sent from your own mail server
Credit Counting
Each recipient counts as one credit, regardless of message size.
Example:
- 1 TO recipient = 1 credit
- 1 TO + 2 CC = 3 credits
- 5 TO + 3 CC + 2 BCC = 10 credits
Authentication
API Key (for sending emails)
Use your API key to send emails:
X-API-Key: rk_your_api_keySession Token (for key management)
Get a session token by logging in, then use it to manage API keys:
Authorization: Bearer your_session_tokenKey types: API keys (rk_) are for sending emails.
Master keys (mk_) are for programmatic account management.
Send Email API
Requires API key (X-API-Key header).
/api_fe/send_email_feSend an email using your API key.
Request Body
{
"to_chirho": ["recipient@example.com"], // Required: array of recipient emails
"cc_chirho": ["cc@example.com"], // Optional: array of CC emails
"bcc_chirho": ["bcc@example.com"], // Optional: array of BCC emails
"reply_to_chirho": "replyto@example.com", // Optional: reply-to address
"subject_chirho": "Email Subject", // Required: email subject
"body_text_chirho": "Plain text body", // Optional*: plain text version
"body_html_chirho": "<p>HTML body</p>" // Optional*: HTML version
}
// * At least one of body_text_chirho or body_html_chirho is requiredSuccess Response (200)
{
"status_chirho": "sent_chirho",
"emails_remaining_chirho": 9999
}Error Response (4xx/5xx)
{
"error_chirho": "Invalid API key"
}/api_fe/send_test_email_feSend a test email to verify your configuration.
/api_fe/usage_feGet current usage statistics for your API key.
{
"emails_remaining_chirho": 9999,
"emails_sent_chirho": 1
}Key Management API
Requires session token authentication (Authorization: Bearer).
/api_fe/keys_feCreate a new API key with SMTP configuration.
curl -X POST https://2smtp.com/api_fe/keys_fe \
-H "Authorization: Bearer your_session_token" \
-H "Content-Type: application/json" \
-d '{
"smtp_host_chirho": "smtp.gmail.com",
"smtp_port_chirho": 587,
"smtp_user_chirho": "your-email@gmail.com",
"smtp_pass_chirho": "your-app-password",
"smtp_tls_chirho": true,
"from_email_chirho": "your-email@gmail.com",
"label_chirho": "Production"
}'/api_fe/keys_feList all API keys with details.
curl https://2smtp.com/api_fe/keys_fe \
-H "Authorization: Bearer your_session_token"/api_fe/update_key_label_feUpdate the label for an API key.
/api_fe/deactivate_key_feDeactivate an API key permanently.
/api_fe/test_smtp_feTest SMTP connection before creating a key.
Credits & Usage API
Requires session token authentication.
/api_fe/credits_feGet credit pool balance.
curl https://2smtp.com/api_fe/credits_fe \
-H "Authorization: Bearer your_session_token"/api_fe/usage_stats_feGet daily and per-key usage statistics.
{
"total_credits_chirho": 10000,
"used_credits_chirho": 500,
"remaining_credits_chirho": 9500,
"total_emails_sent_chirho": 500
}/api_fe/history_feGet email send history (last 100 sends).
/api_fe/checkout_feCreate a Stripe checkout session to purchase credits.
Master Keys API
Master keys allow programmatic management of your 2SMTP account for automation and AI integration.
/api_fe/master_keys_feCreate a new master key with optional scopes and expiration.
/api_fe/master_keys_feList all master keys (shows preview only, not full key).
/api_fe/master_keys_feRevoke a master key by its preview.
Code Examples
cURL
curl -X POST https://2smtp.com/api_fe/send_email_fe \
-H "X-API-Key: rk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"to_chirho": ["recipient@example.com"],
"subject_chirho": "Hello from 2SMTP!",
"body_text_chirho": "This is a plain text email.",
"body_html_chirho": "<h1>Hello!</h1><p>This is an HTML email.</p>"
}'JavaScript / TypeScript
const response = await fetch('https://2smtp.com/api_fe/send_email_fe', {
method: 'POST',
headers: {
'X-API-Key': 'rk_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
to_chirho: ['recipient@example.com'],
subject_chirho: 'Hello from 2SMTP!',
body_text_chirho: 'This is a plain text email.',
body_html_chirho: '<h1>Hello!</h1><p>This is an HTML email.</p>'
})
});
const data = await response.json();
console.log(data.status_chirho); // "sent_chirho"
console.log(data.emails_remaining_chirho); // 9999Python
import requests
response = requests.post(
'https://2smtp.com/api_fe/send_email_fe',
headers={
'X-API-Key': 'rk_your_api_key',
'Content-Type': 'application/json'
},
json={
'to_chirho': ['recipient@example.com'],
'subject_chirho': 'Hello from 2SMTP!',
'body_text_chirho': 'This is a plain text email.',
'body_html_chirho': '<h1>Hello!</h1><p>This is an HTML email.</p>'
}
)
data = response.json()
print(data['status_chirho']) # "sent_chirho"
print(data['emails_remaining_chirho']) # 9999Rate Limits
Important: Rate limits protect your SMTP server's reputation. Sending too fast can trigger spam filters and blacklisting.
- 50 emails per minute per API key
- 1,000 recipients per single request (TO + CC + BCC combined)
- Rate limit headers are included in responses
Rate Limit Headers
X-RateLimit-Remaining-Chirho: 95 X-RateLimit-Reset-Chirho: 1735200000Error Codes
| Status | Meaning |
|---|---|
| 400 | Bad request - invalid parameters |
| 401 | Unauthorized - invalid or missing API key |
| 403 | Forbidden - no credits remaining or key lacks required scope |
| 404 | Resource not found |
| 429 | Rate limit exceeded |
| 500 | Server error |
Common SMTP Providers
When creating an API key, you'll need your SMTP credentials. Here are settings for popular providers:
Gmail / Google Workspace
smtp.gmail.com Port:587 (TLS) or 465 (SSL) Username:your-email@gmail.com Password:App Password (not your regular password)Outlook / Microsoft 365
smtp.office365.com Port:587Amazon SES
email-smtp.[region].amazonaws.com Port:587SendGrid
smtp.sendgrid.net Port:587 Username:apikey Password:Your SendGrid API keyOpenAPI Specification
Full machine-readable API documentation in OpenAPI 3.0.3 format.
MCP Integration (Coming Soon)
MCP server integration for AI assistants like Claude Desktop is planned.
remail_send_email- Send an email via API keyremail_list_keys- List all API keysremail_get_usage- View usage statistics
Need Help?
Having trouble integrating? Check our pricing page for FAQs or contact us for support.