{"openapi":"3.1.0","info":{"title":"RESTAPI.email Headless Inbound API","version":"2.0.0","description":"Create an agent inbox, then receive messages at its address. Retrieve messages or configure a signed webhook with the API key returned during registration. Access requires an active subscription: registering creates an identity, and an inbox, API key or received message each require a live entitlement. Messages and raw MIME are retained for 30 days. File attachments are discarded before storage; inline images remain available in HTML email content. Quotas are account-wide and shared across the inboxes an account owns. Authentication and challenge endpoints are rate limited and answer 429 with a Retry-After header. Unexpected failures return JSON carrying a `ref` field; quote it to support."},"servers":[{"url":"https://api.restapi.email"}],"components":{"securitySchemes":{"AgentKey":{"type":"apiKey","in":"header","name":"X-API-Key"},"BearerAuth":{"type":"http","scheme":"bearer"}}},"paths":{"/api/api-keys":{"get":{"summary":"List human API keys","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"API keys"}}},"post":{"summary":"Create a human API key","security":[{"BearerAuth":[]}],"responses":{"201":{"description":"One-time API key"},"403":{"description":"The account has no active subscription, or already holds the number of keys its plan allows."}}}},"/api/auth/login":{"post":{"summary":"Sign in to a human account","responses":{"200":{"description":"Bearer token and account. The session ends after 7 days of disuse and slides forward each time it is used, up to an absolute cap of 30 days from sign-in. Revoke it with POST /api/auth/logout."},"401":{"description":"Invalid credentials"},"429":{"description":"Rate limited: 5 requests per minute per IP and per account. Retry after the number of seconds in the Retry-After header."}}}},"/api/auth/register":{"post":{"summary":"Register a human account","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string","format":"email"},"password":{"type":"string","minLength":12},"name":{"type":"string"}}}}}},"responses":{"201":{"description":"Accepted. Returns no token and answers identically whether or not the address was already registered; sign in with POST /api/auth/login. Registration creates an identity only: no inbox, no allowance and no entitlement until a subscription is active."},"429":{"description":"Rate limited: 3 requests per minute per IP. Retry after the number of seconds in the Retry-After header."}}}},"/api/emails":{"get":{"summary":"List human inboxes","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"Inboxes"}}},"post":{"summary":"Create a human inbox","security":[{"BearerAuth":[]}],"responses":{"201":{"description":"Inbox created"},"403":{"description":"The account has no active subscription, or already holds the number of inboxes its plan allows."}}}},"/api/emails/{inboxId}":{"patch":{"summary":"Rename, activate or deactivate an inbox","description":"An account is created with an inbox named after its email address. Renaming is how that address is changed; how many inboxes an account may hold depends on its plan. Mail already received keeps the address it was sent to.","security":[{"BearerAuth":[]}],"parameters":[{"name":"inboxId","in":"path","required":true,"description":"The inbox id, or its current address.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"type":"object","required":["action","email_address"],"properties":{"action":{"type":"string","enum":["rename"]},"email_address":{"type":"string","description":"The new address. Must be on the inbox domain."}}},{"type":"object","required":["action"],"properties":{"action":{"type":"string","enum":["activate","deactivate"]}}}]}}}},"responses":{"200":{"description":"Inbox updated"},"400":{"description":"Unknown action, or an address not on the inbox domain"},"401":{"description":"No valid session"},"404":{"description":"Inbox not found, or owned by another account"},"409":{"description":"That address is already taken"}}}},"/api/pricing":{"get":{"summary":"List purchasable plans","responses":{"200":{"description":"Plans that can currently be bought, each with its monthly and annual amount taken from Stripe. Returns an empty list with purchasable=false when billing is not open or no plan has a complete price set."}}}},"/api/usage":{"get":{"summary":"Current usage against plan allowances","description":"Account-wide usage for each metered allowance, measured with the same queries that enforce it. `warnings` lists any allowance at or above `threshold_percent`, with severity \"critical\" once it is spent and mail is being refused. `percent` is null for an allowance of zero, which means the account holds no subscription rather than that it is full.","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"Usage, allowances and any warnings"},"401":{"description":"Missing or invalid bearer token"}}}},"/api/v1/agents/challenge":{"get":{"summary":"Get a proof-of-work registration challenge","responses":{"200":{"description":"Challenge"},"429":{"description":"Rate limited: 10 requests per minute per IP. Retry after the number of seconds in the Retry-After header."}}}},"/api/v1/agents/subscriptions":{"post":{"summary":"Request a subscribed inbox for an agent, to be confirmed and paid for by its human owner","description":"Replaces free self-registration once plans are on sale. Solve a challenge from GET /api/v1/agents/challenge, name the plan and the owner's email address, and hand the returned checkout_url to the owner. The owner signs in as that address, confirms the request and pays. Poll status_url with the request_secret as a bearer token; when status is active the response carries the agent's api_key exactly once. The request expires after seven days if nobody confirms it. Nothing is created and nothing is charged until the owner confirms.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["handle","description","plan","owner_email","pow_challenge","pow_nonce"],"properties":{"handle":{"type":"string","description":"3-32 lowercase letters, digits or hyphens; becomes handle@agent.restapi.email"},"description":{"type":"string","description":"20-300 characters, shown to the owner"},"plan":{"type":"string","enum":["seed","builder","scale"]},"billing_interval":{"type":"string","enum":["monthly","yearly"],"default":"monthly"},"owner_email":{"type":"string","format":"email","description":"The human who will confirm and pay. Only an account signed in as this address can see or confirm the request."},"idempotency_key":{"type":"string","description":"Optional. Repeating a request with the same key, handle and owner_email returns the existing request instead of creating another."},"pow_challenge":{"type":"string"},"pow_nonce":{"type":"string"}}}}}},"responses":{"200":{"description":"An existing request matched the idempotency key; returned without the secret"},"201":{"description":"Pending request with request_id, request_secret (shown once), checkout_url for the owner and status_url to poll"},"400":{"description":"Invalid input or proof of work"},"409":{"description":"Handle already registered or requested"},"429":{"description":"Rate limited"},"503":{"description":"Subscriptions are not open"}}}},"/api/v1/agents/subscriptions/{requestId}":{"get":{"summary":"Check an agent subscription request, and collect the API key once it is active","description":"Authenticate with the request_secret as a bearer token. While the owner has not confirmed, status is pending or awaiting_payment. Once active, the first call returns api_key and later calls do not; expired and failed requests say so.","security":[{"BearerAuth":[]}],"parameters":[{"name":"requestId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Request status; includes api_key exactly once after activation"},"401":{"description":"Missing or unknown request secret"},"404":{"description":"The secret does not belong to this request"},"429":{"description":"Rate limited"}}}},"/api/v1/agents/me":{"get":{"summary":"Get the authenticated agent, including its inbox address","security":[{"AgentKey":[]}],"responses":{"200":{"description":"Agent, including the inbox address mail should be sent to"},"401":{"description":"Missing or invalid X-API-Key"}}}},"/api/v1/agents/register":{"post":{"summary":"Register an agent and create its inbox (closed while paid plans are on sale)","description":"Free self-registration predates paid plans. While billing is on, every call answers 402 and points at POST /api/v1/agents/subscriptions, which is how an agent obtains an inbox now. Agents registered before plans went on sale keep working.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["handle","description","pow_challenge","pow_nonce"],"properties":{"handle":{"type":"string"},"description":{"type":"string"},"owner_contact":{"type":"string"},"pow_challenge":{"type":"string"},"pow_nonce":{"type":"string"}}}}}},"responses":{"201":{"description":"Agent and one-time API key"},"400":{"description":"Invalid registration"},"402":{"description":"Self-registration is closed while paid plans are on sale; the body names the subscription endpoint to use instead"},"409":{"description":"Handle already exists"}}}},"/api/v1/emails/{address}/messages":{"get":{"summary":"List messages for an owned inbox","description":"Newest first. Also answers to a human account's sk_live_ API key for that account's inboxes.\n\nWait for a verification email in one call: note the time (or the id of the newest message) before triggering the sign-up, then call `GET /api/v1/emails/{address}/messages?since=2026-11-19T10:00:00.000Z&wait=25`. Repeat on an empty list. When a message comes back, `GET /api/v1/emails/{address}/messages/{id}` and read `email.extracted.codes[0]` or `email.extracted.links[0]`.","security":[{"AgentKey":[]}],"parameters":[{"name":"address","in":"path","required":true,"schema":{"type":"string"}},{"name":"page","in":"query","schema":{"type":"integer","minimum":1}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100}},{"name":"cursor","in":"query","description":"Opaque cursor from a previous response's pagination.next_cursor. Stable while new mail arrives, unlike page. Overrides page when both are given; an unreadable cursor is ignored.","schema":{"type":"string"}},{"name":"q","in":"query","description":"Full-text search across subject and body.","schema":{"type":"string"}},{"name":"since","in":"query","description":"Only messages received strictly after this point: an ISO 8601 timestamp (compared with received_at), or the id of a message in this inbox (the message itself is excluded). Combines with every other filter and with cursor paging. A malformed value, or an id not in this inbox, is a 400.","schema":{"type":"string"},"example":"2026-11-19T10:00:00.000Z"},{"name":"wait","in":"query","description":"Long-poll for up to this many seconds (0-25, default 0). Applies only when nothing matches: the request then holds until a matching message arrives (checked about once a second) or the time runs out, and answers as it otherwise would -- an empty list with 200 on timeout. A long poll counts as one request for rate limiting, and each key may start up to 30 long polls a minute; past that the request answers at once, as with wait=0. Set your HTTP client's timeout above the wait.","schema":{"type":"integer","minimum":0,"maximum":25,"default":0}}],"responses":{"200":{"description":"Messages, newest first. List items carry metadata only; fetch a message for its body and `extracted` codes and links."},"400":{"description":"Invalid since or wait"},"401":{"description":"Missing or invalid X-API-Key"},"403":{"description":"Inbox is not owned by this API key"},"429":{"description":"Rate limited. Authenticated reads are shed above roughly 120 requests per minute per API key; the limit is approximate. Retry after the seconds in the Retry-After header."}}}},"/api/v1/emails/{address}/messages/{messageId}":{"get":{"summary":"Get a message, including raw MIME","description":"Returns the message under `email`, with `extracted`: likely one-time codes and links pulled from the subject, text and HTML. Extraction is a heuristic -- check the body when a code matters.","security":[{"AgentKey":[]}],"responses":{"200":{"description":"Message","content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"object","properties":{"id":{"type":"string"},"subject":{"type":["string","null"]},"text_content":{"type":["string","null"]},"html_content":{"type":["string","null"]},"received_at":{"type":"string","format":"date-time"},"extracted":{"type":"object","required":["codes","links"],"properties":{"codes":{"type":"array","maxItems":5,"description":"Likely one-time codes, most likely first: 4-8 digits, or 6-8 character uppercase letter-and-digit tokens, found near words such as code, OTP, verification, passcode or PIN. Years, phone numbers, prices, postcodes, order numbers and CSS colours are excluded. Empty when nothing qualifies.","items":{"type":"string"},"example":["582014"]},"links":{"type":"array","maxItems":20,"description":"http(s) links from the text and from HTML hrefs, deduplicated. Links that look like verification, confirmation, activation, magic-link, sign-in, token or reset links come first; the rest follow in document order. Unsubscribe links, images and tracking pixels are left out.","items":{"type":"string","format":"uri"},"example":["https://acme.example/verify?token=abc"]}}}}}}}}}},"401":{"description":"Missing or invalid X-API-Key"},"404":{"description":"Message not found"},"429":{"description":"Rate limited. Authenticated reads are shed above roughly 120 requests per minute per API key; the limit is approximate. Retry after the seconds in the Retry-After header."}}},"delete":{"summary":"Delete a message","description":"Removes the message's content, addresses and stored raw MIME immediately and permanently. The message still counts towards the inbox's monthly message allowance (deleting does not refund quota), but its storage is released. Returns 404 for a message already deleted.","security":[{"AgentKey":[]}],"responses":{"200":{"description":"Deleted; the body carries the message id"},"401":{"description":"Missing or invalid X-API-Key"},"404":{"description":"Message not found, or already deleted"}}}},"/api/v1/emails/{address}/webhooks":{"get":{"summary":"List inbox webhooks","security":[{"AgentKey":[]}],"responses":{"200":{"description":"Webhooks"},"401":{"description":"Missing or invalid X-API-Key"}}},"post":{"summary":"Create an inbox webhook","security":[{"AgentKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["url"],"properties":{"url":{"type":"string","format":"uri"},"secret":{"type":"string"}}}}}},"responses":{"201":{"description":"Webhook and one-time secret"},"401":{"description":"Missing or invalid X-API-Key"}}}},"/api/v1/emails/{address}/webhooks/{webhookId}":{"delete":{"summary":"Delete an inbox webhook","security":[{"AgentKey":[]}],"responses":{"200":{"description":"Deleted"},"401":{"description":"Missing or invalid X-API-Key"},"404":{"description":"Webhook not found"}}}},"/mcp":{"post":{"summary":"Remote MCP server (Streamable HTTP) exposing inboxes as tools","description":"A stateless Model Context Protocol endpoint (protocol versions 2025-06-18 and 2025-03-26) for MCP clients such as Claude Code or Cursor. Each POST carries one JSON-RPC 2.0 message and is answered with application/json; batches, SSE streams and sessions are not used, and GET answers 405. Authenticate with the same sk_live_ or sk_agent_ key as the REST API, as X-API-Key or Authorization: Bearer; a key reads exactly the inboxes it can read over REST, and each tools/call counts as one request against its rate limit. Tools: list_inboxes, list_messages, wait_for_message, get_message, get_verification_code, delete_message. Claude Code: claude mcp add --transport http restapi-email https://api.restapi.email/mcp --header \"X-API-Key: sk_...\"","security":[{"AgentKey":[]},{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["jsonrpc","method"],"properties":{"jsonrpc":{"type":"string","enum":["2.0"]},"id":{"type":["string","integer"],"description":"Omitted for notifications."},"method":{"type":"string","description":"initialize, notifications/initialized, ping, tools/list or tools/call."},"params":{"type":"object"}}}}}},"responses":{"200":{"description":"JSON-RPC response"},"202":{"description":"Notification accepted; no body"},"400":{"description":"Parse error, invalid request, batch, or unsupported MCP-Protocol-Version"},"401":{"description":"Missing or invalid API key; carries WWW-Authenticate: Bearer"},"403":{"description":"Browser Origin not allowed"}}}},"/health":{"get":{"summary":"Health check","responses":{"200":{"description":"Service healthy"}}}}}}