API docs

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.app

JSON 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.

Terminal
# 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://…", …}

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:

Terminal · Claude Code
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.

TokenLooks likeWhat it can doWhere it comes from
API keym7_…Everything in your account: all inboxes, sandboxes, messages and keys.The API keys window, or POST /v1/keys. Shown once.
Inbox tokenm7i_…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

GET/v1/keysList keys: { keys: [{ id, name, hint, created_at, last_used_at }] }. hint is the last 4 characters.
POST/v1/keysBody { "name": "ci" }. Returns { id, name, key, hint }. This is the only time the full key is returned.
DELETE/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.

GET/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.
POST/v1/auth/logoutEnds the session.
POST/v1/auth/logout-allEnds every session of the account, on every device.
GET/v1/meThe account behind the key or session: { user: { id, email, created_at } }.
DELETE/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.

POST/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 fieldMeaning
nameThe 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.
labelA note for yourself, up to 60 characters.

Request bodies are JSON.

201 Created · anonymous temp inbox
{
  "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.

GET/v1/inboxesYour account’s inboxes, newest first: { inboxes: [...] }. Each has total and unread message counts. Needs an API key.
GET/v1/inboxes/:idOne inbox with total and unread.
PATCH/v1/inboxes/:idBody { "label": "Staging" }. Renames the inbox.
DELETE/v1/inboxes/:idDeletes the inbox and all its mail. Returns { "ok": true }.
POST/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.
GET/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

GET/v1/inboxes/:id/messagesMessages in one inbox, newest first.
GET/v1/messagesMessages across every inbox in your account, newest first. Needs an API key.

Both take the same query parameters:

ParameterMeaning
qText found in the subject, sender address, sender name or preview.
fromText found in the sender address.
subjectText found in the subject.
unread=trueOnly unread messages.
starred=trueOnly starred messages.
limitMessages per page, 1 to 100. Default 50.
beforeOnly messages received before this time. Pass the next_before of the last page to get the next one.
200 OK
{
  "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.

GET/v1/messages/:idOne message in full.
200 OK · full message
{
  "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"
}
FieldMeaning
otpThe 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_linkThe 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.
linksEvery http(s) link in the HTML with its link text, up to 100. For text-only mail, the URLs found in the text.
toThe addresses the message was sent to (the SMTP envelope). In a sandbox this is every recipient your app named.
textThe plain text part. If the mail has only HTML, text made from it.
has_attachmentstrue when there is a file that is not an inline image.
attachments[].cidSet for inline images referenced from the HTML as cid:….
PATCH/v1/messages/:idBody { "read": true, "starred": true }, either or both. Returns the message without bodies.
DELETE/v1/messages/:idDeletes the message and its attachments.
DELETE/v1/inboxes/:id/messagesEmpties the inbox.
GET/v1/messages/:id/rawThe original message, byte for byte, as message/rfc822 (.eml).
GET/v1/messages/:id/attachments/:attOne attachment as a download. :att is the attachment id, like att_1. Send the same Authorization header.
POST/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.

GET/v1/inboxes/:id/waitReturns the newest matching message in full, or 408 with code timeout.
ParameterMeaning
timeoutSeconds to wait. Default 30, at most 60. With 0 it checks once and returns.
sinceOnly messages received after this time: ISO 8601 or epoch milliseconds.
qText found in the subject, sender address, sender name or preview.
fromText found in the sender address.
subjectText found in the subject.
unread=trueOnly unread messages.
starred=trueOnly 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 with subject or from, so you get the one you mean.
  • Set your HTTP client’s timeout a few seconds above timeout.
Terminal
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.

GET/v1/inboxes/:id/wsEvents for one inbox. Works with an inbox token or an API key, passed as ?token=.
GET/v1/wsEvents for every inbox in your account. Needs an API key as ?token=.
Browser or Node 22+
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.

Terminal
# 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
POST/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.

ProviderEndpointWhere the sandbox password goes
SendGridPOST /v3/mail/sendAuthorization: Bearer m7s_…
PostmarkPOST /email, POST /email/batchX-Postmark-Server-Token: m7s_…
MailgunPOST /v3/:domain/messagesBasic auth, user api, password m7s_…. Any domain name is accepted.
Terminal
# 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.

409 Conflict
{ "error": { "code": "name_taken", "message": "qa-signup@mail7.app is taken. Try another name." } }
StatusCodeWhen
400bad_jsonThe body is not valid JSON.
400bad_nameThe inbox name is not 3-40 characters of letters, digits, dots, dashes or underscores, or it is reserved (admin, support and similar).
400bad_datebefore or since is not an ISO 8601 date or epoch milliseconds.
400emptyA raw message upload had no body.
400not_sandboxAn SMTP password was asked for an inbox that is not a sandbox.
401unauthorizedThe endpoint needs an account. Send an API key.
401bad_keyThe API key is not valid.
401bad_tokenThe inbox token is not valid. The inbox may have expired.
403inbox_limitThe account already holds 5 inboxes and sandboxes.
403key_limitThe account already holds 10 API keys.
403captchaAn inbox was asked for with no API key and no solved bot check. From code, send an API key.
404not_foundNo such inbox, message, attachment or endpoint. An expired inbox and someone else’s inbox look the same.
408timeoutwait ended with no matching message.
409name_takenThe address is in use, or it was deleted in the last 90 days and is held so nobody else can take it.
413too_bigA raw message upload is over 5 MB.
429rate_limitedMore than 120 requests in a minute from one account, inbox or IP address.
429daily_limitThe account received its 100 messages for today. Resets at 00:00 UTC.
500internalOur fault. Try again.

Limits

WhatLimit
Inbox made without an accountLives 24 hours, then it is deleted with its mail
Inbox in an accountDoes not expire
Message retention7 days
Messages per inboxNewest 200 are kept; older ones are removed
Inboxes per account5 (temp inboxes and sandboxes together)
Messages received per day100 per account, counted across its inboxes. Resets at 00:00 UTC. A guest inbox gets the same on its own.
Reusing an addressA deleted or expired address cannot be registered again for 90 days
API keys per account10
Message size5 MB
Page size for lists50 by default, 100 at most (limit)
wait timeout30 seconds by default, 60 at most
Requests120 per minute per account (per IP address without one)
Inboxes without an accountBrowser only, behind a bot check. 20 per minute per IP address
Sign-in attempts20 per minute per IP address

These are the free plan’s limits. A Pro plan with higher ones is coming soon. See pricing.

Mail7

No new notifications

New mail shows up here.