# RESTAPI.email (full) > 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_..."}}}} ``` ## Endpoints All paths are relative to `https://api.restapi.email`. This list is a summary; https://api.restapi.email/openapi.json is the current contract, including query parameters and response fields. Messages (`X-API-Key`: `sk_live_` or `sk_agent_` key): - `GET /api/v1/emails/{address}/messages`: list messages, newest first. Returns `emails` and `pagination` (`page`, `limit`, `count`, `has_more`, `next_cursor`). `limit` is 1 to 100 (default 50); pass `cursor=` for stable paging while mail arrives; `q` is a full-text search over subject and body. - `GET /api/v1/emails/{address}/messages/{messageId}`: one message as `email`, with `id`, `from`, `envelope_from`, `to`, `subject`, `text_content`, `html_content`, `attachments`, `headers`, `raw_content`, `status`, `received_at`, `created_at`. - `DELETE /api/v1/emails/{address}/messages/{messageId}`: delete a message now. Webhooks for agent inboxes (`X-API-Key: sk_agent_...`): - `GET /api/v1/emails/{address}/webhooks`: list. - `POST /api/v1/emails/{address}/webhooks`: body `{"url": "https://..."}`; HTTPS only. The response carries the signing secret once. - `DELETE /api/v1/emails/{address}/webhooks/{webhookId}`: remove. Agent identity and subscription: - `GET /api/v1/agents/challenge`: a proof-of-work challenge (`challenge_id`, `data`, `prefix`, `expires_at`). Solve it by finding a `nonce` where the lowercase hex SHA-256 of `challenge_id + data + nonce` starts with `prefix`. - `POST /api/v1/agents/subscriptions`: request an inbox. Body: `handle` (3 to 32 lowercase letters, digits or hyphens; the inbox becomes `handle@agent.restapi.email`), `description` (20 to 300 characters), `plan` (`seed`, `builder` or `scale`), optional `billing_interval` (`monthly` or `yearly`), `owner_email`, `pow_challenge`, `pow_nonce`, optional `idempotency_key`. Returns `request_secret` (shown once), `checkout_url` for the owner and `status_url`. The owner is also emailed the link. - `GET /api/v1/agents/subscriptions/{requestId}` with `Authorization: Bearer `: status. Once the owner has confirmed and paid, the first call after activation returns the `api_key`; later calls do not. - `GET /api/v1/agents/me`: the agent's own record and inbox address. - `POST /api/v1/agents/register`: free self-registration, closed while plans are on sale (answers 402 and points at the subscription flow). Human account routes (`Authorization: Bearer ` from `POST /api/auth/login`, which takes `{"email", "password"}`): - `GET /api/emails`, `POST /api/emails`: list or create inboxes (`{"email_address": "name@agent.restapi.email"}`), within the plan's inbox allowance. - `GET /api/api-keys`, `POST /api/api-keys`: list or create `sk_live_` keys (`{"name": "...", "email_address": optional inbox to restrict to}`); the key is shown once. - `GET /api/webhooks`, `POST /api/webhooks`, `DELETE /api/webhooks/{id}`: account webhooks (`{"url": "https://...", "email_address": optional inbox}`); the secret is shown once. - `GET /api/usage`: standing against each allowance, with warnings at 80%. Public: - `GET /api/pricing`: purchasable plans with live prices and allowances. - `GET /health`: service and database status. Requests are rate limited per key (120 a minute); a 429 means slow down. ## Webhook payload and verification ```json { "event": "message.received", "message": { "id": "...", "from": "sender@example.com", "envelope_from": "bounce+abc123@mail.example.com", "to": "my-agent@agent.restapi.email", "subject": "...", "text_content": "...", "html_content": "...", "headers": {}, "status": "received", "received_at": "2026-11-19T12:00:00.000Z", "extracted": { "codes": ["582014"], "links": ["https://example.com/verify?token=abc"] } } } ``` The payload has no raw MIME; fetch the message for that. `extracted` is the same as on message detail. Verify the signature over the exact raw body before parsing: ```js import crypto from 'node:crypto'; function isValidWebhook(rawBody, signature, secret) { const expected = `sha256=${crypto.createHmac('sha256', secret).update(rawBody).digest('hex')}`; return signature.length === expected.length && crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected)); } ``` ```python import hashlib, hmac def is_valid_webhook(raw_body: bytes, signature: str, secret: str) -> bool: expected = "sha256=" + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest() return hmac.compare_digest(signature or "", expected) ``` Answer 2xx within five seconds. A failed attempt is retried after 30 seconds, 5 minutes, 30 minutes and 2 hours (five attempts in all). Only `https://` endpoints are accepted; redirects are followed for at most three hops, each re-checked (`https://`, public host). ## 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 - [Short version](https://restapi.email/llms.txt): the llms.txt index ## 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