Email Endpoints

API endpoints for sending and managing emails.

POST/mail/send

Send a single email.

REQUEST BODY

FieldTypeRequiredDescription
fromstringrequiredSender email address
tostring | string[]requiredRecipient email address(es)
subjectstringrequiredEmail subject line
htmlstringoptionalHTML content
textstringoptionalPlain text fallback
replyTostringoptionalReply-to address
templateIdstringoptionalTemplate ID to use
templateVariablesobjectoptionalVariables for template rendering
scheduledAtISO 8601optionalSchedule send time
Example Request
curl -X POST "https://api.stack0.dev/mail/send" \
-H "Authorization: Bearer sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"from": "you@yourdomain.com",
"to": "recipient@example.com",
"subject": "Hello!",
"html": "<p>Hello world</p>"
}'
GET/mail/emails/{id}

Get a single email by ID.

Example Request
curl "https://api.stack0.dev/mail/emails/email_xxx" \
-H "Authorization: Bearer sk_live_your_api_key"
GET/mail/emails

List emails with optional filters.

QUERY PARAMETERS

ParameterTypeDescription
limitnumberMax results (default 50, max 100)
offsetnumberOffset for pagination
statusstringFilter by status
fromstringFilter by sender
tostringFilter by recipient
POST/mail/batch

Send multiple emails with different content.

Example Request
curl -X POST "https://api.stack0.dev/mail/batch" \
-H "Authorization: Bearer sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"emails": [
{
"from": "noreply@yourdomain.com",
"to": "user1@example.com",
"subject": "Hello User 1",
"html": "<p>Message for user 1</p>"
},
{
"from": "noreply@yourdomain.com",
"to": "user2@example.com",
"subject": "Hello User 2",
"html": "<p>Message for user 2</p>"
}
]
}'
POST/mail/broadcast

Send the same email to multiple recipients.

Example Request
curl -X POST "https://api.stack0.dev/mail/broadcast" \
-H "Authorization: Bearer sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"from": "newsletter@yourdomain.com",
"to": ["user1@example.com", "user2@example.com"],
"subject": "Weekly Newsletter",
"html": "<h1>This week in tech...</h1>"
}'
POST/mail/emails/{id}/cancel

Cancel a scheduled email before it's sent.

POST/mail/emails/{id}/resend

Resend an existing email.