Documentation
API Documentation
Authenticate with API keys and send transactional email through POST /api/v1/message.
Quick start
- Verify your sending domain in the control panel.
- Create an API key scoped to that domain.
- Call
POST /api/v1/messagewith a Bearer token.
Authentication
Include your API key in the Authorization header on every request.
Authorization: Bearer ms_live_…
POST /api/v1/message
Send JSON with a sender, recipients, and either HTML or text content. Requests must include application/json.
curl -X POST https://mailsurge.dev/api/v1/message \
-H "Authorization: Bearer ms_live_…" \
-H "Content-Type: application/json" \
-d '{
"from": "Acme <noreply@yourdomain.com>",
"to": "user@example.com",
"subject": "Welcome",
"html": "<p>Hello!</p>"
}'Request body
from(string, required): Sender address, e.g. Sender Name <no-reply@yourdomain.com>.to(string|array, required): Recipient email or array of emails.subject(string, required): Message subject line.html(string, optional): HTML body.text(string, optional): Plain text body.cc(string|array, optional)bcc(string|array, optional)reply_to(string|array, optional)headers(object, optional): Custom headers, e.g. {"X-Campaign": "welcome"}.attachments(array, optional): filename, content (base64 or raw text), content_type, disposition, content_id.
Responses
201 Createdon success with an empty body (message is queued for delivery).401 Unauthorizedwith{"reason": "Invalid key"}.403 Forbiddenwhen the account is blocked or pending approval.400 Bad Requestwhen the from domain is invalid or not verified.413 Payload Too Largewhen attachments exceed 20MB or the queue payload exceeds 1MB.422 Unprocessable Entitywith validation errors for invalid input.429 Too Many Requestswhen the request rate exceeds 10/s per API key or 60/min per IP, or when new account sending limits are reached.
Notes
- Recipient fields accept a single email string or an array of emails.
- Provide at least one of
htmlortext. - Verify your sender domain before sending production traffic.
- Rate limits:
10requests per second per API key and60requests per minute per IP. - For inline images, set
dispositiontoinline, provide acontent_id, and reference it as<img src="cid:your-content-id">.