API documentation

Create inboxes, wait for mail and read codes from scripts and end-to-end tests. Every request uses a token of your account and only reaches your own inboxes.

Authentication

Create a token under Settings → API and send it as a bearer token. Each token has its own permissions; requests outside them are answered with 403.

curl -X POST https://tosspost.com/api/v1/mailboxes \
  -H "Authorization: Bearer $TOSSPOST_TOKEN" \
  -H "Accept: application/json" \
  -d lifetime=10

Base URL: https://tosspost.com/api/v1. Responses are JSON, wrapped in "data". A token may send 120 requests per minute.

Endpoints

GET/mailboxesmailboxes:read
List your active inboxes.
POST/mailboxesmailboxes:write
Create an inbox. Optional: local_part, domain, lifetime (10, 60 or 1440 minutes, or 0 to wait for the first mail), permanent, label, origin (the website the address is for, as host or URL).
GET/mailboxes/{id}mailboxes:read
Show one inbox.
PATCH/mailboxes/{id}/extendmailboxes:write
Add 10 minutes to the lifetime, up to an hour ahead. Answers 422 for permanent inboxes and when the maximum is reached.
DELETE/mailboxes/{id}?keep_name=mailboxes:write
Delete an inbox with all of its messages. The name is free again at once; with keep_name=1 it stays reserved like after the inbox expires, so nobody else can take the address.
POST/mailboxes/{id}/rejectedmailboxes:write
Report that a website refused the inbox and get the same name on another domain, the one that site most likely takes. Optional: origin.
GET/mailboxes/{id}/messages?since=messages:read
List messages, newest first, optionally only those received after an ISO 8601 time.
GET/mailboxes/{id}/messages/wait?timeout=&after=messages:read
Wait for the next message. Answers 200 with the message or 204 when none arrived in time. With after (the id of a message) it answers with the message received after that one.
GET/messages/{id}messages:read
Show a message with text, sanitized HTML, code, link and attachments.
GET/messages/{id}/rawmessages:read
Download the raw source as .eml.
GET/messages/{id}/previous?scope=messages:read
Compare a message with the previous one of its template (else the previous one from the same sender with a similar subject): that message and the changed lines of the text (diff.lines with op same, added or removed). With scope=account every inbox of your account is searched, for test runs that create a fresh inbox each time.
GET/attachments/{id}messages:read
Download an attachment.

An inbox created with origin returns it as origin_host. Every message then carries foreign_sender: true when the sender domain is neither that host nor one of its subdomains, a hint that the address was passed on.

The wait endpoint holds the request for up to 30 seconds. Two waiting requests per account may run at once.

Test SDK

With the npm package @tosspost/playwright, every test gets its own inbox that is deleted afterwards. waitForCode() and waitForLink() wait for the next mail and return its code or confirmation link.

npm install --save-dev @tosspost/playwright
export TOSSPOST_API_TOKEN="…"
export TOSSPOST_BASE_URL="https://tosspost.com"
import { test, expect } from '@tosspost/playwright';

test('sign-up sends a confirmation code', async ({ page, inbox }) => {
  await page.goto('https://your-app.example/sign-up');
  await page.getByLabel('E-mail').fill(inbox.address);
  await page.getByRole('button', { name: 'Sign up' }).click();

  await page.getByLabel('Code').fill(await inbox.waitForCode());
  await expect(page.getByText('Welcome')).toBeVisible();
});

The token needs the permissions mailboxes:write and messages:read. Each mail is returned only once, and options such as subject or from pick a particular one.

Example: Playwright

A sign-up test that waits for the confirmation code instead of sleeping.

import { test, expect } from '@playwright/test';

const api = 'https://tosspost.com/api/v1';
const headers = {
  Authorization: `Bearer ${process.env.TOSSPOST_TOKEN}`,
  Accept: 'application/json',
};

test('sign-up sends a confirmation code', async ({ page, request }) => {
  const created = await request.post(`${api}/mailboxes`, { headers });
  const { data: inbox } = await created.json();

  await page.goto('https://your-app.example/sign-up');
  await page.getByLabel('E-mail').fill(inbox.address);
  await page.getByRole('button', { name: 'Sign up' }).click();

  const waited = await request.get(
    `${api}/mailboxes/${inbox.id}/messages/wait?timeout=30`,
    { headers, timeout: 35_000 },
  );
  expect(waited.status()).toBe(200);

  const { data: message } = await waited.json();
  await page.getByLabel('Code').fill(message.verification_code);

  await request.delete(`${api}/mailboxes/${inbox.id}`, { headers });
});

Shortcut on iPhone and iPad

One tap creates an address and copies it, straight from the home screen or the share sheet. Build it once in the Shortcuts app:

  1. Create a token with the permission mailboxes:write under Settings → API.
  2. Add the action "Get Contents of URL" with the URL https://tosspost.com/api/v1/mailboxes, the method POST, the headers Authorization (Bearer and your token) and Accept (application/json), and a form body with lifetime = 0.
  3. Add "Get Dictionary Value" for the key data, then again for the key address.
  4. Finish with "Copy to Clipboard".

With lifetime = 0 the address waits for the first mail. On Android and on the desktop, use the installed app instead: press and hold its icon and pick the shortcut for a new address.

Webhooks

A webhook receives a POST with this body for every new message. The content of the message is included only if you switch it on.

{
  "event": "message.received",
  "delivery_id": "01JB…",
  "mailbox": { "id": "01JA…", "address": "quiet-falcon-42@tosspost.test", "label": null },
  "message": {
    "id": "01JB…",
    "from": { "address": "team@shop.example", "name": "Shop Team" },
    "subject": "Your confirmation code",
    "preview": "Your code is 482913.",
    "verification_code": "482913",
    "verification_url": null,
    "size": 1834,
    "received_at": "2026-10-17T08:00:00+00:00"
  }
}

Check the signature before you trust a delivery: X-TossPost-Signature is an HMAC-SHA256 over "{timestamp}.{body}" with the secret of the webhook, X-TossPost-Timestamp the time in seconds.

import crypto from 'node:crypto';

// rawBody is the request body exactly as received, before JSON parsing.
function isFromTossPost(rawBody, headers, secret) {
  const timestamp = headers['x-tosspost-timestamp'];
  const expected = crypto
    .createHmac('sha256', secret)
    .update(`${timestamp}.${rawBody}`)
    .digest('hex');
  const fresh = Math.abs(Date.now() / 1000 - Number(timestamp)) < 300;

  return fresh && crypto.timingSafeEqual(
    Buffer.from(expected),
    Buffer.from(headers['x-tosspost-signature'] ?? ''),
  );
}

Answer with a 2xx status within 10 seconds. Redirects are not followed. A failed delivery is retried three times; after 10 failed deliveries in a row the webhook is switched off. Webhook URLs must be public https addresses.

A permanent inbox with a mail heartbeat (My inboxes → Heartbeat) also sends heartbeat.late when its test mail is overdue, heartbeat.failing when it fails DKIM or arrives later than the grace, and heartbeat.recovered when it is back, each once per change. Their body has event, delivery_id, mailbox and heartbeat (status, interval_minutes, grace_minutes, last_seen_at, last_delay_seconds, last_dkim_ok, due_at), never the content of a mail.

AI agents (MCP)

Agents that fill in sign-up forms get their own inboxes through the Model Context Protocol. Connect your MCP client with a token of your account; the same permissions and limits apply as for the API.

{
  "mcpServers": {
    "tosspost": {
      "url": "https://tosspost.com/mcp",
      "headers": { "Authorization": "Bearer YOUR_TOKEN" }
    }
  }
}

Tools: create_inbox, wait_for_code, read_message, list_inboxes and delete_inbox. wait_for_code returns the newest confirmation code or link, so an agent can finish a sign-up on its own.

Mail is written by strangers and may contain instructions aimed at AI agents. That is why agents get the code, the sender and a confirmation link only when it leads to the sender's own site; the text itself only with the extra permission messages:read-full, together with the phrases in it that address an AI (instructions_found).

A sign-in, magic or password reset link opens an account, so an agent gets it only after you allow it: the tools answer with approval (status pending) and ask the browsers that follow your account (Settings → Approvals). Allow within two minutes and the next call of wait_for_code or read_message returns the link, once; the full text hides it until then. This covers what TossPost hands out; a link the agent already has is out of its reach. The REST API is for your own code and hands out messages as they are.