AssertInbox

Let your coding agent test email flows

An AI coding agent that builds or fixes a sign-up form can click through it in a browser, but it cannot read the confirmation email without a real inbox. This page shows how to give it one: connect the AssertInbox MCP server, and add a short block of instructions to your repository so that every agent session uses the inbox the same safe way. You need an API key from /start.

Why an agent needs a real inbox

Many flows cannot be completed without email. A sign-up sends a verification link, a login sends a one-time code, a password reset sends a magic link. Without a mailbox, an agent has two bad options: stop and ask a human to read the email, or mock the mail layer and test less than what users experience. With an AssertInbox address the agent can run the whole flow itself: create an address, submit the form, wait for the message, read the otp or magic_link field and finish the sign-up.

Each address has the form <namespace>.<tag>@assertinbox.com. The namespace belongs to your key, and the tag is any name the agent chooses, so a fresh tag per run keeps runs apart. Messages are deleted after 24 hours.

Connect the MCP server

Add the server to your agent's MCP configuration. The file name and exact keys differ by client; check your client's documentation. The generic shape, the same as on the MCP reference, is:

{
  "mcpServers": {
    "assertinbox": {
      "url": "https://assertinbox.com/mcp",
      "headers": {
        "Authorization": "Bearer <your API key>"
      }
    }
  }
}

Keep the key out of files that are committed. Most clients can read a header value from an environment variable or from a local, untracked settings file; use whichever your client offers. The agent then has five tools: create_address, wait_for_email, list_messages, get_message and delete_messages.

Add instructions to your repository

Many agents read a plain-text instructions file in the repository before they start, for example AGENTS.md. Check your tool's documentation for the file name it expects. Add the following section to it. It contains no secret: the key and namespace are read from environment variables that you set outside the repository.

# Email testing with AssertInbox

Use AssertInbox when a flow sends an email that you must read: sign-up
verification, one-time codes, magic links, password resets.

## Setup
- The API key is in the environment variable ASSERTINBOX_KEY and the
  namespace in ASSERTINBOX_NAMESPACE. Never print, log, echo or commit
  the key, and never write it into a file in this repository.
- Addresses look like <namespace>.<tag>@assertinbox.com.
- Only use these addresses with apps that I own or control.

## Procedure
1. Pick one new, unique tag for every test run, for example
   signup-<timestamp>. Never reuse a tag from an earlier run.
2. Fill in the form or call the API with <namespace>.<tag>@assertinbox.com.
3. Only then wait for the email: the MCP tool wait_for_email or
   GET https://assertinbox.com/v1/wait?tag=<tag>. Pass "after" (the id of
   the last message handled) or "since" (the Unix time just before the
   trigger) so an older email is never picked up. Add "subject" when the
   flow sends more than one email.
4. A timeout (HTTP 408) means no email arrived yet. Wait again a few
   times, then report the failure and what the app showed.
5. Read the "otp" field for a code and "magic_link" for a link. Fall back
   to "links" or the text body only if they are null.
6. When the test is done, delete the tag's messages: the MCP tool
   delete_messages with the tag, or DELETE /v1/messages?tag=<tag>.

Set ASSERTINBOX_KEY and ASSERTINBOX_NAMESPACE in the environment where the agent runs. The start page shows both values once, right after you create the key. Do not paste the key into the instructions file; the block above deliberately names only the variables.

Why these rules

Fallback: REST with curl

An agent without MCP support can run shell commands instead. The same three steps work with plain HTTP; the full list of endpoints is in the API reference.

TAG="run-$(date +%s)"
ADDRESS="$ASSERTINBOX_NAMESPACE.$TAG@assertinbox.com"

# ...trigger the email for $ADDRESS here...

curl -s -H "Authorization: Bearer $ASSERTINBOX_KEY" \
  "https://assertinbox.com/v1/wait?tag=$TAG&timeout=25"

curl -s -X DELETE -H "Authorization: Bearer $ASSERTINBOX_KEY" \
  "https://assertinbox.com/v1/messages?tag=$TAG"

The wait call returns the newest matching message as JSON, with otp, magic_link and links. If it returns 408 with the code timeout, nothing has arrived yet and the agent should call it again. A request that returns 429 means the key has used its daily allowance; see the limits page.

Check that it works

Ask the agent to run a flow on a small app of yours, such as a local sign-up form, and watch the tool calls. A good run shows create_address or a new tag, the form submission, one wait_for_email call that returns the message, the code or link being used, and a delete_messages call at the end. If a wait times out every time, look at what the app did after the form was submitted: an error banner means no email was sent. The AI agent sign-up guide has a reusable prompt and a troubleshooting list, and the MCP guide covers configuration for several clients.

For test suites that run without an agent, the same inboxes work from Playwright, Cypress, pytest and other tools; see the guides and the client files.