Email Endpoints
API endpoints for sending and managing emails.
POST
/mail/sendSend a single email.
REQUEST BODY
| Field | Type | Required | Description |
|---|---|---|---|
| from | string | required | Sender email address |
| to | string | string[] | required | Recipient email address(es) |
| subject | string | required | Email subject line |
| html | string | optional | HTML content |
| text | string | optional | Plain text fallback |
| replyTo | string | optional | Reply-to address |
| templateId | string | optional | Template ID to use |
| templateVariables | object | optional | Variables for template rendering |
| scheduledAt | ISO 8601 | optional | Schedule 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/emailsList emails with optional filters.
QUERY PARAMETERS
| Parameter | Type | Description |
|---|---|---|
| limit | number | Max results (default 50, max 100) |
| offset | number | Offset for pagination |
| status | string | Filter by status |
| from | string | Filter by sender |
| to | string | Filter by recipient |
POST
/mail/batchSend 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/broadcastSend 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}/cancelCancel a scheduled email before it's sent.
POST
/mail/emails/{id}/resendResend an existing email.