Docs
Base URL: https://assertinbox.com. All responses are JSON. The full machine-readable description is openapi.json.
Step-by-step examples are in the guides.
Contents
- 1. Get a key
- 2. Send mail to an address
- 3. Read it
- Trigger, then wait for the new email
- Examples for every endpoint
- Playwright
- Cypress
- MCP for AI agents
- How extraction works
- Limits
1. Get a key
In a browser, /start creates a key in one click and shows ready-to-paste snippets.
curl -s -X POST https://assertinbox.com/v1/keys
The response has api_key (shown once; store it) and namespace. Key creation is limited to 3 per IP address per hour. A 403 signups_closed means the beta is not open for new keys.
2. Send mail to an address
Any address of the form <namespace>.<tag>@assertinbox.com works. A tag uses letters, digits, dots, dashes and underscores, up to 64 characters, and is case-insensitive. Mail for an unknown namespace is rejected during delivery.
3. Read it
| Request | Result |
|---|---|
GET /v1/messages?tag=&since=&from=&subject=&after= | Up to 50 messages, newest first. since is a Unix time in seconds. Omit tag for all tags. |
GET /v1/messages/{id} | One message. |
GET /v1/wait?tag=&since=&from=&subject=&after=&timeout= | The newest matching message, or 408 timeout. timeout is seconds, default 20, maximum 25. |
GET /v1/me | Your namespace, address template, whether you are activated, messages received in the last 24 hours, API calls today and your limits. |
DELETE /v1/messages?tag= | Deletes the messages for a tag, or all of your messages without tag. |
POST /v1/keys/me/rotate | Returns a new api_key for the same namespace. The old key stops working at once. Messages are kept. |
DELETE /v1/keys/me | Deletes all your messages and usage counters and permanently disables the key. Returns {"deleted": true}. The namespace is never issued again and mail to it is rejected. |
from and subject match a case-insensitive substring of the sender or subject (% and _ are matched literally). after is a message id: only messages that arrived after that one are returned. The same parameters work in the MCP tools wait_for_email and list_messages.
Trigger, then wait for the new email
/v1/wait returns the newest matching message even if it arrived before your call. When a test sends a second email to the same tag (a resent code, then a password reset), read the id of the last message you handled and pass it as after, or pass the time just before the trigger as since. Add subject to pick the right email.
# 1. note the newest message id (empty on the first run)
LAST=$(curl -s -H "Authorization: Bearer $ASSERTINBOX_KEY" "https://assertinbox.com/v1/messages?tag=signup-1" | jq -r '.messages[0].id // empty')
# 2. trigger the email in your app, then wait for one newer than $LAST
curl -s -H "Authorization: Bearer $ASSERTINBOX_KEY" \
"https://assertinbox.com/v1/wait?tag=signup-1&subject=reset&after=$LAST&timeout=20"
Send Authorization: Bearer <api_key> on each request. A message looks like this:
{"id":"2f1c0b1e-0000-4000-8000-000000000001","tag":"signup-1","ts":1796464450,"from":"noreply@example.com","subject":"Your code","text":"Your verification code is 482913","html":"","otp":"482913","magic_link":"https://example.com/verify?t=abc","links":["https://example.com/verify?t=abc"]}
otp is the first 4 to 8 digit code found near words such as code, OTP or verification, or else a bare 6-digit number; it is null when none is found. links lists every http(s) link in the HTML and text parts.
Examples for every endpoint
Each example shows one request and the response body. Set ASSERTINBOX_KEY to your key first.
POST /v1/keys
curl -s -X POST https://assertinbox.com/v1/keys
{"api_key":"ai_0123456789abcdef","namespace":"k3x9a1bz"}
GET /v1/messages
curl -s -H "Authorization: Bearer $ASSERTINBOX_KEY" \
"https://assertinbox.com/v1/messages?tag=signup-1&subject=welcome"
{"messages":[{"id":"2f1c0b1e-0000-4000-8000-000000000001","tag":"signup-1","ts":1796464450,"from":"noreply@example.com","subject":"Welcome","text":"Welcome aboard","html":"","otp":null,"magic_link":null,"links":[]}]}
GET /v1/messages/{id}
curl -s -H "Authorization: Bearer $ASSERTINBOX_KEY" \
https://assertinbox.com/v1/messages/2f1c0b1e-0000-4000-8000-000000000001
{"id":"2f1c0b1e-0000-4000-8000-000000000001","tag":"signup-1","ts":1796464450,"from":"noreply@example.com","subject":"Your code","text":"Your verification code is 482913","html":"","otp":"482913","magic_link":null,"links":[]}
GET /v1/wait
curl -s -H "Authorization: Bearer $ASSERTINBOX_KEY" \
"https://assertinbox.com/v1/wait?tag=signup-1&timeout=20"
{"id":"2f1c0b1e-0000-4000-8000-000000000001","tag":"signup-1","ts":1796464450,"from":"noreply@example.com","subject":"Your code","text":"Your verification code is 482913","html":"","otp":"482913","magic_link":null,"links":[]}
On timeout the response is 408 with {"error":"timeout","message":"..."}; call again.
GET /v1/me
curl -s -H "Authorization: Bearer $ASSERTINBOX_KEY" https://assertinbox.com/v1/me
{"namespace":"k3x9a1bz","address_template":"k3x9a1bz.<tag>@assertinbox.com","created_at":1796460000,"activated":true,"messages_today":3,"api_calls_today":12,"limits":{"messages_per_day":200,"api_calls_per_day":2000,"retention_hours":24}}
DELETE /v1/messages
curl -s -X DELETE -H "Authorization: Bearer $ASSERTINBOX_KEY" \
"https://assertinbox.com/v1/messages?tag=signup-1"
{"ok":true}
POST /v1/keys/me/rotate
curl -s -X POST -H "Authorization: Bearer $ASSERTINBOX_KEY" \
https://assertinbox.com/v1/keys/me/rotate
{"api_key":"ai_fedcba9876543210","namespace":"k3x9a1bz"}
DELETE /v1/keys/me
curl -s -X DELETE -H "Authorization: Bearer $ASSERTINBOX_KEY" \
https://assertinbox.com/v1/keys/me
{"deleted":true}
Playwright
import { test, expect } from "@playwright/test";
const API = "https://assertinbox.com";
const KEY = process.env.ASSERTINBOX_KEY;
const NAMESPACE = process.env.ASSERTINBOX_NAMESPACE;
test("sign up with an emailed code", async ({ page }) => {
const tag = "pw-" + Date.now();
await page.goto("https://your-app.example/signup");
await page.fill("input[name=email]", NAMESPACE + "." + tag + "@assertinbox.com");
await page.click("button[type=submit]");
const res = await fetch(API + "/v1/wait?tag=" + tag + "&timeout=25", {
headers: { Authorization: "Bearer " + KEY },
});
expect(res.status).toBe(200);
const mail = await res.json();
await page.fill("input[name=code]", mail.otp);
await page.click("button[type=submit]");
});
Cypress
Cypress.Commands.add("latestEmail", (tag) => {
return cy.request({
url: "https://assertinbox.com/v1/wait?tag=" + tag + "&timeout=25",
headers: { Authorization: "Bearer " + Cypress.env("ASSERTINBOX_KEY") },
failOnStatusCode: false,
timeout: 30000,
}).then((res) => {
expect(res.status).to.eq(200);
return res.body;
});
});
MCP for AI agents
AI agents can use the same inboxes through a remote MCP server (streamable HTTP, JSON-RPC) at https://assertinbox.com/mcp. Authenticate with the same Authorization: Bearer <api_key> header. Tools:
create_address: returns a fresh address<namespace>.<tag>@assertinbox.com. The tag is optional.wait_for_email: waits up to 25 seconds for a message with a given tag and returns it withotpandlinks. On timeout it returns an error result; call it again.list_messages: lists up to 50 received messages, optionally for one tag.
Client configuration (for clients that accept a remote HTTP server with headers):
{
"mcpServers": {
"assertinbox": {
"type": "http",
"url": "https://assertinbox.com/mcp",
"headers": { "Authorization": "Bearer YOUR_API_KEY" }
}
}
}
How extraction works
otp: a 4 to 8 digit code that follows a label such as code, OTP, passcode, PIN, verification or sign-in on the same line. Codes written as123 456or123-456are returned as123456. A labelled upper-case code that mixes letters and digits (for exampleK7Q2XZ) is also returned. If nothing is labelled, a lone 6-digit number is used. Order numbers, years without a label and phone numbers are skipped. Otherwise it isnull.links: every http(s) link from the HTML and text parts, in order, without duplicates (at most 50).magic_link: the first link whose URL or visible text contains verify, confirm, magic, login, sign in, token or reset. Unsubscribe, privacy, help and image links are ignored. Otherwise it isnull.- Only the first 50,000 characters of the HTML are searched. Extraction is heuristic: always check the full message for unusual formats.
Limits
The complete list of limits and error codes is on the limits page. Single-file clients for Node.js and Python are described on the client files page.
- Messages are kept 24 hours, then deleted.
- 2,000 API requests per key per UTC day, MCP calls included. Above that the API returns
429 rate_limitedwith aRetry-Afterheader (seconds until 00:00 UTC). - 200 received messages per namespace per day; the stored body is capped at about 1 MB.
- Errors are JSON with
error(a stable code) andmessage. Codes:unauthorized(401),key_disabled(403),signups_closed(403),not_found(404),timeout(408),rate_limited(429),tag_required(400).
Use this service only for accounts and services you own or control. See the terms.