Skip to content

API integration

Prefer HTTP over SMTP? You can capture email in an inbox by POSTing it to the MailSandbox API. This is handy for tooling, tests, or apps that build messages themselves.

Each inbox has its own API key (prefixed with “ms_”), found on the inbox’s Configuration screen. Send it with every request in either of these headers:

X-API-Key: ms_your_inbox_api_key
# or, equivalently:
Authorization: Bearer ms_your_inbox_api_key

The API key identifies the inbox, so every message you post is captured in that inbox.

POST a JSON body to the emails endpoint:

Terminal window
curl -X POST https://mailsandbox.com/api/emails \
-H "X-API-Key: ms_your_inbox_api_key" \
-H "Content-Type: application/json" \
-d '{
"subject": "Welcome to Acme",
"from_email": "hello@acme.test",
"from_name": "Acme",
"to": ["jane@example.com"],
"html": "<h1>Hello Jane</h1>"
}'

Fields:

  • subject — the email subject (required)
  • from_email — sender address (required); from_name — sender name (optional)
  • to — array of recipient addresses (required)
  • html — the HTML body; text — the plain-text body. Provide at least one of the two.
  • headers — optional object of extra headers

A successful request returns the created message:

{
"message": "Email created successfully",
"data": {
"id": 123,
"subject": "Welcome to Acme",
"inbox_id": 7,
"created_at": "2026-07-18T10:00:00Z"
}
}
  • 401 — the API key is missing or invalid
  • 422 — validation failed; the response lists the errors

Captured messages appear in the inbox immediately, ready to preview, inspect and share.