API Reference
Emails
The Emails API allows you to send individual emails, manage email scheduling, track email status, and handle batch email operations.
Base URL
https://api.unsent.dev/v1/emailsFeatures
Send individual emails
Send single emails with customizable content
Batch email sending
Send multiple emails in a single API call
Email scheduling
Schedule emails to be sent at specific times
Email tracking
Retrieve email status and tracking information
Email management
Update or cancel scheduled emails
Attachments
Send files with your emails
Custom headers
Add custom SMTP headers to your emails
Quick Start
Send a simple email
curl -X POST https://api.unsent.dev/v1/emails \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"to": "recipient@example.com",
"from": "sender@yourdomain.com",
"subject": "Hello from Unsent",
"text": "This is a plain text email",
"html": "<p>This is an <strong>HTML</strong> email</p>"
}'Send an email with attachments
curl -X POST https://api.unsent.dev/v1/emails \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"to": "recipient@example.com",
"from": "sender@yourdomain.com",
"subject": "Email with attachment",
"html": "<p>Please find the attached file.</p>",
"attachments": [
{
"filename": "document.pdf",
"content": "base64-encoded-content"
}
]
}'Schedule an email
curl -X POST https://api.unsent.dev/v1/emails \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"to": "recipient@example.com",
"from": "sender@yourdomain.com",
"subject": "Scheduled email",
"html": "<p>This email is scheduled for later.</p>",
"scheduledAt": "2024-12-25T10:00:00Z"
}'API Endpoints
Idempotency
To prevent duplicate operations, you can use the Idempotency-Key header. This is particularly useful when retrying requests due to network errors.
curl -X POST https://api.unsent.dev/v1/emails \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: unique-key-123" \
-d '{
"to": "recipient@example.com",
"from": "sender@yourdomain.com",
"subject": "Hello",
"html": "<p>Hello</p>"
}'Common Use Cases
Transactional Emails
- Password resets
- Order confirmations
- Shipping notifications
- Account verifications
Marketing Emails
- Newsletters
- Promotional campaigns
- Product announcements
- Customer engagement
Automated Notifications
- System alerts
- Status updates
- Reminder emails
- Report deliveries
Rate Limits
- Single emails: 100 emails per minute
- Batch emails: 1000 emails per minute (up to 100 per batch)
- Email retrieval: 100 requests per minute
Best Practices
- Use templates for consistent branding
- Include both text and HTML versions for better deliverability
- Verify your sending domain before sending emails
- Handle bounces and complaints appropriately
- Use batch sending for multiple emails to improve performance
- Test with sandbox mode before going to production