Build with SendBaba API
Powerful, reliable email infrastructure for developers. Send transactional emails, manage campaigns, and track everything in real-time with our simple REST API.
Authentication
Authenticate your API requests using Bearer tokens
Include your API key in the Authorization header of every request:
Authorization: Bearer sb_live_your_api_key_here
Keep Your Key Secure
Never expose API keys in client-side code or public repositories. Use environment variables.
API Key Types
| Prefix | Environment | Description |
|---|---|---|
sb_live_ | Production | Live emails are sent to recipients |
sb_test_ | Sandbox | Emails logged but not delivered |
Quick Start
Send your first email in under 2 minutes
curl -X POST https://api.sendbaba.com/v1/emails/send \ -H "Authorization: Bearer sb_live_your_api_key" \ -H "Content-Type: application/json" \ -d '{ "from": "you@yourdomain.com", "to": "recipient@example.com", "subject": "Hello from SendBaba!", "html": "<h1>Welcome!</h1><p>Your first email.</p>" }'
import requests response = requests.post( "https://api.sendbaba.com/v1/emails/send", headers={ "Authorization": "Bearer sb_live_your_api_key", "Content-Type": "application/json" }, json={ "from": "you@yourdomain.com", "to": "recipient@example.com", "subject": "Hello from SendBaba!", "html": "<h1>Welcome!</h1>" } ) print(response.json())
const response = await fetch('https://api.sendbaba.com/v1/emails/send', { method: 'POST', headers: { 'Authorization': 'Bearer sb_live_your_api_key', 'Content-Type': 'application/json' }, body: JSON.stringify({ from: 'you@yourdomain.com', to: 'recipient@example.com', subject: 'Hello from SendBaba!', html: '<h1>Welcome!</h1>' }) }); const data = await response.json(); console.log(data);
<?php $ch = curl_init('https://api.sendbaba.com/v1/emails/send'); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer sb_live_your_api_key', 'Content-Type: application/json' ], CURLOPT_POSTFIELDS => json_encode([ 'from' => 'you@yourdomain.com', 'to' => 'recipient@example.com', 'subject' => 'Hello from SendBaba!', 'html' => '<h1>Welcome!</h1>' ]) ]); $response = curl_exec($ch); print_r(json_decode($response));
package main import ( "bytes" "encoding/json" "net/http" ) func main() { payload := map[string]string{ "from": "you@yourdomain.com", "to": "recipient@example.com", "subject": "Hello from SendBaba!", "html": "<h1>Welcome!</h1>", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.sendbaba.com/v1/emails/send", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer sb_live_your_api_key") req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() }
Send Email
Send a single transactional email
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
from | string | Required | Sender email address |
to | string | array | Required | Recipient email(s) |
subject | string | Required | Email subject line |
html | string | Optional | HTML body content |
text | string | Optional | Plain text body |
reply_to | string | Optional | Reply-to address |
cc | array | Optional | CC recipients |
bcc | array | Optional | BCC recipients |
headers | object | Optional | Custom email headers |
tags | array | Optional | Tags for analytics |
metadata | object | Optional | Custom metadata (returned in webhooks) |
Response
202 Accepted{
"success": true,
"message_id": "msg_abc123xyz789",
"status": "queued"
}
Batch Send
Send personalized emails to multiple recipients in one request
{
"from": "newsletter@yourdomain.com",
"subject": "Hello !",
"html": "<h1>Hi </h1><p>Your code: </p>",
"recipients": [
{
"email": "john@example.com",
"data": { "first_name": "John", "code": "ABC123" }
},
{
"email": "jane@example.com",
"data": { "first_name": "Jane", "code": "XYZ789" }
}
]
}
Merge Tags
Use syntax for personalization. Variables are replaced per-recipient from the data object.
Campaign API
Create and manage email campaigns programmatically
{
"name": "January Newsletter",
"subject": "🎉 New Year, New Features!",
"from_email": "news@yourdomain.com",
"from_name": "Your Company",
"html_content": "<h1>Happy New Year!</h1>...",
"segment_id": "seg_active_users",
"schedule_at": "2024-01-15T09:00:00Z"
}
Send a draft campaign immediately to all recipients in the target segment.
curl -X POST https://api.sendbaba.com/v1/campaigns/camp_123/send \ -H "Authorization: Bearer sb_live_your_api_key"
{
"campaign_id": "camp_123",
"sent": 15420,
"delivered": 15380,
"opened": 4250,
"clicked": 892,
"bounced": 40,
"unsubscribed": 12,
"open_rate": 27.6,
"click_rate": 5.8
}
SMTP Relay
Use our SMTP servers for applications that don't support REST APIs
SMTP Host
Port (TLS)
Port (SSL)
Encryption
Authentication
| Setting | Value |
|---|---|
Username | Your API key (sb_live_xxx...) |
Password | Your API key (same as username) |
Authentication | LOGIN or PLAIN |
const nodemailer = require('nodemailer'); const transporter = nodemailer.createTransport({ host: 'smtp.sendbaba.com', port: 587, secure: false, auth: { user: 'sb_live_your_api_key', pass: 'sb_live_your_api_key' } }); await transporter.sendMail({ from: 'you@yourdomain.com', to: 'recipient@example.com', subject: 'Hello!', html: '<h1>Welcome</h1>' });
use PHPMailer\PHPMailer\PHPMailer; $mail = new PHPMailer(true); $mail->isSMTP(); $mail->Host = 'smtp.sendbaba.com'; $mail->SMTPAuth = true; $mail->Username = 'sb_live_your_api_key'; $mail->Password = 'sb_live_your_api_key'; $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = 587; $mail->setFrom('you@yourdomain.com'); $mail->addAddress('recipient@example.com'); $mail->Subject = 'Hello!'; $mail->Body = '<h1>Welcome</h1>'; $mail->send();
import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart msg = MIMEMultipart('alternative') msg['Subject'] = 'Hello!' msg['From'] = 'you@yourdomain.com' msg['To'] = 'recipient@example.com' html = '<h1>Welcome</h1>' msg.attach(MIMEText(html, 'html')) with smtplib.SMTP('smtp.sendbaba.com', 587) as server: server.starttls() server.login('sb_live_your_api_key', 'sb_live_your_api_key') server.send_message(msg)
Webhooks
Receive real-time notifications for email events
Event Types
| Event | Description | Trigger |
|---|---|---|
email.sent | Email sent to recipient server | Immediate |
email.delivered | Email delivered to inbox | Real-time |
email.opened | Recipient opened the email | On open |
email.clicked | Recipient clicked a link | On click |
email.bounced | Email bounced | Real-time |
email.complained | Marked as spam | Real-time |
email.unsubscribed | Recipient unsubscribed | On action |
{
"event": "email.delivered",
"timestamp": "2024-01-15T10:30:00Z",
"data": {
"message_id": "msg_abc123xyz789",
"recipient": "john@example.com",
"subject": "Welcome!",
"tags": ["onboarding"],
"metadata": {
"user_id": "usr_123"
}
}
}
Error Handling
Standard HTTP response codes and error formats
| Code | Status | Description |
|---|---|---|
200 | OK | Request successful |
202 | Accepted | Request queued for processing |
400 | Bad Request | Invalid parameters or payload |
401 | Unauthorized | Invalid or missing API key |
403 | Forbidden | Insufficient permissions |
404 | Not Found | Resource doesn't exist |
429 | Too Many Requests | Rate limit exceeded |
500 | Server Error | Internal error, retry later |
{
"success": false,
"error": {
"code": "invalid_recipient",
"message": "The recipient email address is invalid",
"param": "to"
}
}
Rate Limits
API rate limits by plan
| Plan | Requests/Min | Emails/Hour | Emails/Day |
|---|---|---|---|
| Free Trial | 10 | 100 | 500 |
| Starter | 60 | 1,000 | 10,000 |
| Business | 300 | 5,000 | 50,000 |
| Enterprise | 1,000+ | Custom | Custom |
Rate Limit Headers
Check X-RateLimit-Remaining and X-RateLimit-Reset headers in responses.