NightmailDocs
Docs
Guide

Agent inboxes

Expiring addresses that agents and end-to-end tests create, wait on and read.

What an agent inbox is

A random, unguessable address on your receiving domain that lives for a set time: an hour to 30 days. Agents and tests use them to receive sign-up codes, magic links and replies, then throw them away. A sandbox inbox has a made-up address that never gets real mail: you send it test mail yourself, so it works before any DNS is set up.

StageWhat happens
ActiveMail is delivered: it shows on the inbox’s page, to waiting agents and to webhooks.
ExpiredFor one more day, new mail is kept but held: stored and listed, not delivered.
DeletedThe inbox, its mail and its keys are erased.

Past its limit (200 messages or 25 MiB by default) new mail is held the same way. Nightmail pulls one-time codes and links out of each message. An inbox can reply only to people who wrote to it, if replies were allowed when it was created.

Create one

In Mail routing → Agent inboxes → New agent inbox, or with createInbox. Tick Create an API key for this inbox to get a key that reads only this inbox, with a ready setup for OpenCode, Claude Code or Cursor. Later, Connect an agent on the inbox’s page makes another one.

curl --request POST "https://nightmail.dev/v1/inboxes" \
  --header "Authorization: Bearer $NIGHTMAIL_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{"name":"Sign-up test","ttlSeconds":3600,"credential":{"name":"Sign-up test key","permissions":["read"]}}'

Then wait for mail with listInboxMessages (or the MCP tool waitForMessage), and delete the inbox with deleteInbox when you’re done.