# RESTAPI.email > Receive-only email inboxes for AI agents and backend automations. Mail sent to an address at @agent.restapi.email is stored and exposed as JSON over a REST API at https://api.restapi.email, and can also be pushed to a signed HTTPS webhook. There is no mail server to run and no sending. Key facts: - API base: `https://api.restapi.email`. The machine-readable contract is https://api.restapi.email/openapi.json and is the source of truth for parameters and fields; the interactive reference is https://api.restapi.email/docs. - Paid plans only (Seed, Builder, Scale); there is no free plan. Allowances are account-wide. See https://restapi.email/pricing or `GET https://api.restapi.email/api/pricing`. - Messages and raw MIME are kept for 30 days, then deleted. A message can be deleted earlier with `DELETE`. - File attachments are discarded before storage; inline images stay in the HTML. Messages over 1 MiB are rejected. - In a message, `from` is the address in the From header; `envelope_from` is the SMTP envelope sender (bounce address), for bounce handling rather than display. ## Authentication Every API key goes in the `X-API-Key` header. - Human accounts: create an `sk_live_...` key in the dashboard (https://app.restapi.email). It can be limited to one inbox. It reads and deletes messages under `/api/v1/emails/{address}/messages`. - Agents: an `sk_agent_...` key, issued through the agent subscription flow (`POST /api/v1/agents/subscriptions`, approved and paid for by the agent's human owner). It reads and deletes messages and manages webhooks under `/api/v1/emails/{address}/...`. - Dashboard account routes (`/api/emails`, `/api/api-keys`, `/api/webhooks`, `/api/usage`) take the session token from `POST /api/auth/login` as `Authorization: Bearer `, not an API key. ## Quickstart ```bash API=https://api.restapi.email ADDR=my-agent@agent.restapi.email KEY=sk_agent_... # or an sk_live_ key for a human account # List messages, newest first (paginate with page/limit or cursor) curl "$API/api/v1/emails/$ADDR/messages?limit=20" -H "X-API-Key: $KEY" # Get one message: text_content, html_content, headers, raw_content curl "$API/api/v1/emails/$ADDR/messages/MESSAGE_ID" -H "X-API-Key: $KEY" # Add a webhook (agent key); the response shows the signing secret once curl -X POST "$API/api/v1/emails/$ADDR/webhooks" -H "X-API-Key: $KEY" \ -H "Content-Type: application/json" -d '{"url":"https://example.com/hooks/email"}' # Human accounts add webhooks with a session token instead: # curl -X POST "$API/api/webhooks" -H "Authorization: Bearer $TOKEN" \ # -H "Content-Type: application/json" -d '{"url":"https://example.com/hooks/email","email_address":"'$ADDR'"}' # Delete a message (content and stored mail go at once; it still counts toward the month's allowance) curl -X DELETE "$API/api/v1/emails/$ADDR/messages/MESSAGE_ID" -H "X-API-Key: $KEY" ``` Webhook deliveries are `POST` requests with `X-Restapi-Email-Event: message.received` and `X-Restapi-Email-Signature: sha256=`. Failed deliveries are retried after 30s, 5m, 30m and 2h. ## Waiting for a verification email (OTP) Long-poll the list instead of looping: `since` takes a message id or ISO timestamp and returns only newer mail; `wait` (0-25 seconds) holds the request until a matching message arrives, or returns an empty list on timeout. Message detail carries `extracted.codes` (likely one-time codes, best first) and `extracted.links` (verification/login links first; links wrapped by Gmail, Outlook Safe Links or Proofpoint are unwrapped to their destination). Webhook payloads carry the same `extracted`. ```bash # Note the newest id before triggering the sign-up, then wait for the next message LAST=$(curl -s "$API/api/v1/emails/$ADDR/messages?limit=1" -H "X-API-Key: $KEY" | jq -r '.emails[0].id // empty') ID=$(curl -s "$API/api/v1/emails/$ADDR/messages?since=${LAST:-1970-01-01T00:00:00Z}&wait=25" -H "X-API-Key: $KEY" | jq -r '.emails[0].id') curl -s "$API/api/v1/emails/$ADDR/messages/$ID" -H "X-API-Key: $KEY" | jq '.email.extracted' # {"codes":["482913"],"links":["https://example.com/verify?token=..."]} ``` ## MCP server Remote MCP server (Streamable HTTP, stateless): https://api.restapi.email/mcp. Same key as the REST API, as `X-API-Key` or `Authorization: Bearer`; it reads exactly the inboxes the key can read. Tools: `list_inboxes`, `list_messages`, `wait_for_message` (long-poll; text plus extracted codes and links), `get_message`, `get_verification_code` (waits, returns `{code, link, message_id, subject, from}`), `delete_message`. Pass the newest id from `list_messages` as `since` before triggering a sign-up so an old code is not returned. ```bash # Claude Code claude mcp add --transport http restapi-email https://api.restapi.email/mcp --header "X-API-Key: sk_..." ``` ```json {"mcpServers":{"restapi-email":{"type":"http","url":"https://api.restapi.email/mcp","headers":{"X-API-Key":"sk_..."}}}} ``` ## Docs - [OpenAPI document](https://api.restapi.email/openapi.json): the current API contract (JSON) - [API reference](https://api.restapi.email/docs): server-rendered reference (interactive when JavaScript runs); [as Markdown](https://api.restapi.email/docs.md) - [Agent manifest](https://api.restapi.email/agent.json): name, API base and docs location - [Full text for LLMs](https://restapi.email/llms-full.txt): this file plus the endpoint list, agent subscription flow and webhook verification ## Guides - [Docs hub](https://restapi.email/docs): quickstart, authentication, endpoints, long-poll, extraction, webhook signature verification (Node.js and Python), MCP - [MCP setup](https://restapi.email/mcp): connecting Claude Code, Claude Desktop, Cursor and other MCP clients - [Email verification for AI agents](https://restapi.email/use-cases/ai-agent-email-verification): the sign-up/OTP flow over REST and MCP - [Inbound email API](https://restapi.email/use-cases/inbound-email-api): email to JSON, signed webhooks, testing your app's email in CI - [All guides](https://restapi.email/guides): index of the step-by-step guides below - [Claude Code email verification](https://restapi.email/guides/claude-code-email-verification): connect the MCP server to Claude Code, Claude Desktop or Cursor; prompts that pass `since`; scoping the key to one inbox; tool permissions - [OTP email in Playwright tests](https://restapi.email/guides/receive-otp-email-in-playwright-tests): wait for the email with `since` + `wait` instead of sleeps; TypeScript and Python helpers; parallel workers with `q` - [Parse inbound email webhooks](https://restapi.email/guides/parse-inbound-email-webhook): webhook payload, HMAC signature verification (Node.js, Python, Web Crypto), retry schedule, idempotency on `message.id` - [AI agent sign-up automation](https://restapi.email/guides/ai-agent-signup-automation): framework-agnostic `prepare_email_verification` / `get_verification_code` tools over REST, JSON tool schema, OpenAI Agents SDK and LangChain wrappers ## Comparisons Dated, sourced comparisons, including where the other product is the better fit: - [Compare](https://restapi.email/compare): RESTAPI.email against AgentMail, MailSlurp and Mailosaur - [RESTAPI.email vs AgentMail](https://restapi.email/compare/agentmail) - [RESTAPI.email vs MailSlurp](https://restapi.email/compare/mailslurp) - [RESTAPI.email vs Mailosaur](https://restapi.email/compare/mailosaur) ## Product - [Home](https://restapi.email/): what the service does - [Pricing](https://restapi.email/pricing): plans and allowances (prices are read live from `GET https://api.restapi.email/api/pricing`) - [Dashboard](https://app.restapi.email/): register, create inboxes, API keys and webhooks ## Optional - [About](https://restapi.email/about): background and limits - [Contact](https://restapi.email/contact): questions and pilot interest