Skip to content

Use case: agent sign-ups

An email API for AI agents that need to receive verification codes

Your agent creates an account somewhere and the service emails it a one-time code or a magic link. RESTAPI.email gives the agent its own inbox, holds the request until the email arrives, and returns the code and link already pulled out of the message.

Why agents get stuck at the inbox

  • Most services an agent signs up for send a code or a link by email, and the agent has nowhere to receive it.
  • A shared personal mailbox means IMAP credentials in the agent, a human copying codes, or both.
  • Polling a mailbox in a loop is slow to write, burns requests and still returns yesterday’s code.

How the OTP flow works

  1. Step 1

    Give the agent an address

    An inbox such as signup-bot@agent.restapi.email, read with an API key that can be limited to that inbox.

  2. Step 2

    Mark the moment

    Before the agent submits the sign-up form, it takes the newest message id from the inbox.

  3. Step 3

    Wait for the next email

    One request with since=<that id>&wait=25 returns as soon as newer mail lands, or an empty list after 25 seconds.

  4. Step 4

    Use the code

    The message carries extracted.codes and extracted.links, with Gmail, Outlook and Proofpoint redirects unwrapped. Over MCP, get_verification_code returns them directly.

The code

curl
API=https://api.restapi.email
INBOX=signup-bot@agent.restapi.email
KEY=sk_agent_...   # or an sk_live_ key

# 1. Before triggering the sign-up, note the newest message id
LAST=$(curl -s "$API/api/v1/emails/$INBOX/messages?limit=1" \
  -H "X-API-Key: $KEY" | jq -r '.emails[0].id // empty')

# 2. Wait up to 25 seconds for the next email (empty list on timeout: loop)
ID=$(curl -s "$API/api/v1/emails/$INBOX/messages?since=${LAST:-1970-01-01T00:00:00Z}&wait=25" \
  -H "X-API-Key: $KEY" | jq -r '.emails[0].id')

# 3. Read the code and the verification link
curl -s "$API/api/v1/emails/$INBOX/messages/$ID" \
  -H "X-API-Key: $KEY" | jq '.email.extracted'

{ "codes": ["482913"], "links": ["https://example.com/verify?token=..."] }

More in the docs: long-poll, extraction, and MCP setup.

An inbox the agent can ask for itself

An agent can request its own inbox through the API: it names a handle and a plan, and hands its human owner a checkout link. When the owner confirms and pays, the agent collects its own sk_agent_ key and reads handle@agent.restapi.email with it. The inbox counts against the owner’s plan.

What it does not do

  • Send email: it is receive-only.
  • Solve CAPTCHAs or get around a service’s terms. Use it where your agent is allowed to sign up.
  • Keep attachments: they are discarded before storage.
  • Keep mail forever: messages are deleted after 30 days, or earlier on request.

Questions

Does my agent need a mailbox, IMAP or a mail server?

No. The inbox lives on agent.restapi.email and is read over HTTPS with an API key: REST for scripts, MCP for agents that use tools.

What if two emails arrive, or an old code is still in the inbox?

Pass since (the newest message id from before the sign-up) so only newer mail matches. The MCP tools can also narrow by from_contains and subject_contains.

What if no code is found?

Extraction is a heuristic and leaves codes empty rather than guess. The message still has text_content, html_content and headers, so the agent can read it itself.

Can the agent get its own inbox?

Yes. An agent can request an inbox through the API and hand its human owner a checkout link; once the owner confirms and pays, the agent collects its own sk_agent_ key.

Give your agent its own inbox

Create an account, pick a plan, and read your first message with one authenticated request.

Receive-only. Paid plans, by card, cancel any time.