Mail7 API
Make an inbox, send mail to it, read the mail as JSON. The API pulls the one-time code and the verify link out of each message, so a test needs one call to get them.
https://api.mail7.appJSON in, JSON out. Dates are ISO 8601 in UTC. CORS is open, so the API works from a browser.
Quick start
You need an API key. Open API keys, sign in and make one. It takes a minute.
# 1. Make an inbox with your API key (free account, open API keys).
curl -X POST https://api.mail7.app/v1/inboxes -H "Authorization: Bearer m7_…"
# {"id":"inb_4k2m9x7q1c8d","address":"calm-otter-482@mail7.app", …}
# 2. Send mail to that address from your app. Then wait for it (up to 30 seconds).
curl "https://api.mail7.app/v1/inboxes/inb_4k2m9x7q1c8d/wait?timeout=30" \
-H "Authorization: Bearer m7_…"
# {"subject":"Your code","otp":"482913","verify_link":"https://…", …}const API = 'https://api.mail7.app';
const headers = { Authorization: `Bearer ${process.env.MAIL7_KEY}` }; // an API key from mail7.app/keys
const inbox = await fetch(`${API}/v1/inboxes`, { method: 'POST', headers }).then((r) => r.json());
console.log(inbox.address); // use it to sign up in your app
const res = await fetch(`${API}/v1/inboxes/${inbox.id}/wait?timeout=30`, { headers });
if (!res.ok) throw new Error((await res.json()).error.message);
const mail = await res.json();
console.log(mail.otp, mail.verify_link);import os
import requests
API = "https://api.mail7.app"
headers = {"Authorization": f"Bearer {os.environ['MAIL7_KEY']}"} # an API key from mail7.app/keys
inbox = requests.post(f"{API}/v1/inboxes", headers=headers).json()
print(inbox["address"]) # use it to sign up in your app
res = requests.get(
f"{API}/v1/inboxes/{inbox['id']}/wait",
params={"timeout": 30},
headers=headers,
timeout=40,
)
res.raise_for_status()
mail = res.json()
print(mail["otp"], mail["verify_link"])import { test, expect } from '@playwright/test';
const API = 'https://api.mail7.app';
const headers = { Authorization: `Bearer ${process.env.MAIL7_KEY}` }; // an API key from mail7.app/keys
test('sign up with an email code', async ({ page, request }) => {
// a fresh inbox for this test
const inbox = await (await request.post(`${API}/v1/inboxes`, { headers })).json();
await page.goto('https://your-app.example/signup');
await page.getByLabel('Email').fill(inbox.address);
await page.getByRole('button', { name: 'Sign up' }).click();
// one call: returns when the email is in
const res = await request.get(`${API}/v1/inboxes/${inbox.id}/wait?timeout=30`, { headers, timeout: 40_000 });
expect(res.ok()).toBeTruthy();
const mail = await res.json();
await page.getByLabel('Code').fill(mail.otp);
await page.getByRole('button', { name: 'Verify' }).click();
await expect(page.getByText('Welcome')).toBeVisible();
await request.delete(`${API}/v1/inboxes/${inbox.id}`, { headers });
});Inboxes made with a key belong to your account and do not expire. The inbox on the home page needs no account, but it is for people: it sits behind a bot check and cannot be made from code.
AI agents
Coding agents like Claude Code and Cursor can use Mail7 on their own through an MCP server at https://api.mail7.app/mcp. Setup is one command:
claude mcp add --transport http mail7 https://api.mail7.app/mcp --header "Authorization: Bearer m7_…"The AI agents page has the tools, the config for other editors and a snippet for CLAUDE.md. The API is also on one markdown page at /docs.md.
Authentication
Send a token in the Authorization header: Authorization: Bearer <token>. There are two kinds.
| Token | Looks like | What it can do | Where it comes from |
|---|---|---|---|
| API key | m7_… | Everything in your account: all inboxes, sandboxes, messages and keys. | The API keys window, or POST /v1/keys. Shown once. |
| Inbox token | m7i_… | Read and manage one inbox and its messages. | Returned once as token when you make an inbox without an account. |
WebSocket clients in a browser cannot set headers. For those, pass the same token as ?token= in the URL.
Keys are stored hashed. If you lose one, delete it and make another.
API keys
/v1/keysList keys: { keys: [{ id, name, hint, created_at, last_used_at }] }. hint is the last 4 characters./v1/keysBody { "name": "ci" }. Returns { id, name, key, hint }. This is the only time the full key is returned./v1/keys/:idDelete a key. It stops working at once.Account
The site signs in with a session cookie through these. You rarely need them from code.
/v1/auth/startFor browsers, not scripts. Redirects to the hosted sign-in page (MojoAuth), then back to the site with the session cookie set. Scripts use an API key instead./v1/auth/logoutEnds the session./v1/auth/logout-allEnds every session of the account, on every device./v1/meThe account behind the key or session: { user: { id, email, created_at } }./v1/meDeletes the account with every inbox, message and key in it. There is no undo.Inboxes
An inbox has a kind. A temp inbox has a real address at @mail7.app and receives mail from anywhere. A sandbox has no address; it captures what your app sends over SMTP.
/v1/inboxesMake an inbox. With an API key it joins your account and stays. Without one it is a guest inbox: that works only from mail7.app, where the page solves a bot check first.| Body field | Meaning |
|---|---|
name | The part before the @, for example qa-signup. 3-40 characters: lowercase letters, digits, dots, dashes, underscores. Leave it out for a random one like calm-otter-482. |
kind | "temp" (default) or "sandbox". A sandbox needs an API key. |
label | A note for yourself, up to 60 characters. |
Request bodies are JSON.
{
"id": "inb_4k2m9x7q1c8d",
"kind": "temp",
"address": "calm-otter-482@mail7.app",
"label": null,
"created_at": "2026-01-31T12:00:00.000Z",
"expires_at": "2026-02-01T12:00:00.000Z",
"token": "m7i_…"
}token appears only for anonymous inboxes. A sandbox response carries smtp with the password instead. expires_at is null for inboxes in an account.
/v1/inboxesYour account’s inboxes, newest first: { inboxes: [...] }. Each has total and unread message counts. Needs an API key./v1/inboxes/:idOne inbox with total and unread./v1/inboxes/:idBody { "label": "Staging" }. Renames the inbox./v1/inboxes/:idDeletes the inbox and all its mail. Returns { "ok": true }./v1/inboxes/:id/claimBody { "token": "m7i_…" }, sent with an API key. Moves an anonymous inbox into your account so it stops expiring. The inbox token stops working./v1/domainsDomains you can get addresses on: { "domains": ["mail7.app"] }.Plus addressing
Mail to name+anything@mail7.app lands in name@mail7.app. One inbox can stand in for many users: qa+user1@, qa+user2@. The address the mail was sent to is in each message’s to.
Mail to an address with no inbox is rejected. Nobody else can read an address you made.
Messages
/v1/inboxes/:id/messagesMessages in one inbox, newest first./v1/messagesMessages across every inbox in your account, newest first. Needs an API key.Both take the same query parameters:
| Parameter | Meaning |
|---|---|
q | Text found in the subject, sender address, sender name or preview. |
from | Text found in the sender address. |
subject | Text found in the subject. |
unread=true | Only unread messages. |
starred=true | Only starred messages. |
limit | Messages per page, 1 to 100. Default 50. |
before | Only messages received before this time. Pass the next_before of the last page to get the next one. |
{
"messages": [ { "id": "msg_…", "subject": "…", "otp": null, … } ],
"next_before": "2026-01-31T11:58:10.000Z"
}List items have every field up to received_at in the example below. Bodies, headers, links and attachments come with the single message. next_before is null on the last page.
/v1/messages/:idOne message in full.{
"id": "msg_low8y7hhcfjkyk9c",
"inbox_id": "inb_4k2m9x7q1c8d",
"from": { "address": "no-reply@acme.test", "name": "Acme" },
"to": ["calm-otter-482@mail7.app"],
"subject": "Your Acme verification code",
"preview": "Hi there, Your code is 482913. Confirm email",
"otp": "482913",
"verify_link": "https://acme.test/verify?token=abc",
"size": 1013,
"read": false,
"starred": false,
"has_attachments": true,
"received_at": "2026-01-31T12:00:04.120Z",
"text": "Hi there,\nYour code is 482913.\nConfirm email",
"html": "<p>Hi there,</p><p>Your code is <b>482913</b>.</p>…",
"headers": [{ "name": "subject", "value": "Your Acme verification code" }],
"links": [{ "href": "https://acme.test/verify?token=abc", "text": "Confirm email" }],
"attachments": [
{
"id": "att_1",
"filename": "invoice.pdf",
"content_type": "application/pdf",
"size": 48213,
"cid": null,
"url": "https://api.mail7.app/v1/messages/msg_low8y7hhcfjkyk9c/attachments/att_1"
}
],
"raw_url": "https://api.mail7.app/v1/messages/msg_low8y7hhcfjkyk9c/raw"
}| Field | Meaning |
|---|---|
otp | The one-time code found in the subject or text: 4 to 8 digits near words like “code”, “verification” or “PIN”. "123 456" and "123-456" come back as "123456". null when there is none. |
verify_link | The first link that looks like verify, confirm, activate, reset, magic link or sign in. Unsubscribe, help and social links are skipped. null when there is none. |
links | Every http(s) link in the HTML with its link text, up to 100. For text-only mail, the URLs found in the text. |
to | The addresses the message was sent to (the SMTP envelope). In a sandbox this is every recipient your app named. |
text | The plain text part. If the mail has only HTML, text made from it. |
has_attachments | true when there is a file that is not an inline image. |
attachments[].cid | Set for inline images referenced from the HTML as cid:…. |
/v1/messages/:idBody { "read": true, "starred": true }, either or both. Returns the message without bodies./v1/messages/:idDeletes the message and its attachments./v1/inboxes/:id/messagesEmpties the inbox./v1/messages/:id/rawThe original message, byte for byte, as message/rfc822 (.eml)./v1/messages/:id/attachments/:attOne attachment as a download. :att is the attachment id, like att_1. Send the same Authorization header./v1/inboxes/:id/messagesPut a raw RFC 822 message (.eml) into the inbox. The request body is the message. Returns the stored message in full with 201. Use it to seed tests or to capture without SMTP.Wait for mail
The call most tests need. It answers as soon as a matching message exists, so there is no polling loop to write.
/v1/inboxes/:id/waitReturns the newest matching message in full, or 408 with code timeout.| Parameter | Meaning |
|---|---|
timeout | Seconds to wait. Default 30, at most 60. With 0 it checks once and returns. |
since | Only messages received after this time: ISO 8601 or epoch milliseconds. |
q | Text found in the subject, sender address, sender name or preview. |
from | Text found in the sender address. |
subject | Text found in the subject. |
unread=true | Only unread messages. |
starred=true | Only starred messages. |
- Without
since, a message that already arrived counts. “Trigger the email, then call wait” cannot miss it. - If the inbox gets several emails in one test, pass
since(the time just before you triggered the email) or filter withsubjectorfrom, so you get the one you mean. - Set your HTTP client’s timeout a few seconds above
timeout.
curl "https://api.mail7.app/v1/inboxes/inb_…/wait?timeout=45&subject=reset&since=2026-01-31T12:00:00Z" \
-H "Authorization: Bearer m7_…"Live updates
Open a WebSocket to get a push the moment mail lands. This is what the inbox on the home page uses.
/v1/inboxes/:id/wsEvents for one inbox. Works with an inbox token or an API key, passed as ?token=./v1/wsEvents for every inbox in your account. Needs an API key as ?token=.const ws = new WebSocket('wss://api.mail7.app/v1/inboxes/' + inbox.id + '/ws?token=' + inbox.token);
ws.onmessage = (e) => {
if (e.data === 'pong') return;
const event = JSON.parse(e.data);
// { type: 'message', inbox_id: 'inb_…', message: { id, from, subject, otp, … } }
console.log(event.message.subject);
};
setInterval(() => ws.send('ping'), 30_000); // optional keep-alive, answered with "pong"There is one event type, message. Its message has the same fields as a list item; fetch /v1/messages/:id for the body.
SMTP sandbox
A sandbox is an inbox your app sends into. Point your app’s SMTP settings at it and every email is stored there. Nothing is delivered to the real recipients. The SMTP sandbox page has settings for common frameworks.
# create a sandbox (needs an API key)
curl -X POST https://api.mail7.app/v1/inboxes \
-H "Authorization: Bearer m7_…" -H "Content-Type: application/json" \
-d '{"kind":"sandbox","label":"Staging"}'
# {"id":"sbx_…","kind":"sandbox","address":null,"label":"Staging",
# "smtp":{"host":"smtp.mail7.app","port":2525,"username":"sbx_…","password":"m7s_…","tls":false}, …}
# no SMTP client at hand? post a raw .eml over HTTPS instead
curl -X POST https://api.mail7.app/v1/inboxes/sbx_…/messages \
-H "Authorization: Bearer m7_…" --data-binary @mail.eml/v1/inboxes/:id/smtp-passwordMakes a new SMTP password and returns { smtp: { host, port, username, password, tls } }. The old password stops working at once.The password is shown when the sandbox is made and after a reset, never otherwise. Reading a sandbox’s messages works like any inbox: /messages, /wait, /ws.
Already use SendGrid, Postmark or Mailgun?
Keep your code. Point the SDK at https://api.mail7.app and use the sandbox password (m7s_…) where the provider’s API key goes. The send call answers the way the provider does, and the email is captured in the sandbox. Only sending is covered, not templates, stats or webhooks.
| Provider | Endpoint | Where the sandbox password goes |
|---|---|---|
| SendGrid | POST /v3/mail/send | Authorization: Bearer m7s_… |
| Postmark | POST /email, POST /email/batch | X-Postmark-Server-Token: m7s_… |
| Mailgun | POST /v3/:domain/messages | Basic auth, user api, password m7s_…. Any domain name is accepted. |
# SendGrid
curl -X POST https://api.mail7.app/v3/mail/send \
-H "Authorization: Bearer m7s_…" -H "Content-Type: application/json" \
-d '{"personalizations":[{"to":[{"email":"user@example.com"}]}],"from":{"email":"app@example.com"},
"subject":"Hello","content":[{"type":"text/html","value":"<p>Hello</p>"}]}'
# 202, no body
# Postmark
curl -X POST https://api.mail7.app/email \
-H "X-Postmark-Server-Token: m7s_…" -H "Content-Type: application/json" \
-d '{"From":"app@example.com","To":"user@example.com","Subject":"Hello","HtmlBody":"<p>Hello</p>"}'
# {"To":"user@example.com","SubmittedAt":"…","MessageID":"msg_…","ErrorCode":0,"Message":"OK"}
# Mailgun
curl --user "api:m7s_…" https://api.mail7.app/v3/example.com/messages \
-F from="app@example.com" -F to="user@example.com" -F subject="Hello" -F html="<p>Hello</p>"
# {"id":"<msg_…@example.com>","message":"Queued. Thank you."}Errors
Every error has the same shape. code is stable and safe to branch on. message is written for people and may change.
{ "error": { "code": "name_taken", "message": "qa-signup@mail7.app is taken. Try another name." } }| Status | Code | When |
|---|---|---|
| 400 | bad_json | The body is not valid JSON. |
| 400 | bad_name | The inbox name is not 3-40 characters of letters, digits, dots, dashes or underscores, or it is reserved (admin, support and similar). |
| 400 | bad_date | before or since is not an ISO 8601 date or epoch milliseconds. |
| 400 | empty | A raw message upload had no body. |
| 400 | not_sandbox | An SMTP password was asked for an inbox that is not a sandbox. |
| 401 | unauthorized | The endpoint needs an account. Send an API key. |
| 401 | bad_key | The API key is not valid. |
| 401 | bad_token | The inbox token is not valid. The inbox may have expired. |
| 403 | inbox_limit | The account already holds 5 inboxes and sandboxes. |
| 403 | key_limit | The account already holds 10 API keys. |
| 403 | captcha | An inbox was asked for with no API key and no solved bot check. From code, send an API key. |
| 404 | not_found | No such inbox, message, attachment or endpoint. An expired inbox and someone else’s inbox look the same. |
| 408 | timeout | wait ended with no matching message. |
| 409 | name_taken | The address is in use, or it was deleted in the last 90 days and is held so nobody else can take it. |
| 413 | too_big | A raw message upload is over 5 MB. |
| 429 | rate_limited | More than 120 requests in a minute from one account, inbox or IP address. |
| 429 | daily_limit | The account received its 100 messages for today. Resets at 00:00 UTC. |
| 500 | internal | Our fault. Try again. |
Limits
| What | Limit |
|---|---|
| Inbox made without an account | Lives 24 hours, then it is deleted with its mail |
| Inbox in an account | Does not expire |
| Message retention | 7 days |
| Messages per inbox | Newest 200 are kept; older ones are removed |
| Inboxes per account | 5 (temp inboxes and sandboxes together) |
| Messages received per day | 100 per account, counted across its inboxes. Resets at 00:00 UTC. A guest inbox gets the same on its own. |
| Reusing an address | A deleted or expired address cannot be registered again for 90 days |
| API keys per account | 10 |
| Message size | 5 MB |
| Page size for lists | 50 by default, 100 at most (limit) |
wait timeout | 30 seconds by default, 60 at most |
| Requests | 120 per minute per account (per IP address without one) |
| Inboxes without an account | Browser only, behind a bot check. 20 per minute per IP address |
| Sign-in attempts | 20 per minute per IP address |
These are the free plan’s limits. A Pro plan with higher ones is coming soon. See pricing.