# RESTAPI.email Headless Inbound API (v2.0.0)

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.

- Interactive reference: https://api.restapi.email/docs
- Markdown reference: https://api.restapi.email/docs.md
- OpenAPI document: https://api.restapi.email/openapi.json
- LLM index: https://api.restapi.email/llms.txt
- Full LLM guide: https://restapi.email/llms-full.txt

## Servers

- https://api.restapi.email

## Authentication

- **AgentKey**: API key in header `X-API-Key`
- **BearerAuth**: HTTP bearer (Authorization: Bearer <token>)

## Endpoints

- `GET /api/api-keys` - List human API keys
- `POST /api/api-keys` - Create a human API key
- `POST /api/auth/login` - Sign in to a human account
- `POST /api/auth/register` - Register a human account
- `GET /api/emails` - List human inboxes
- `POST /api/emails` - Create a human inbox
- `PATCH /api/emails/{inboxId}` - Rename, activate or deactivate an inbox
- `GET /api/pricing` - List purchasable plans
- `GET /api/usage` - Current usage against plan allowances
- `GET /api/v1/agents/challenge` - Get a proof-of-work registration challenge
- `POST /api/v1/agents/subscriptions` - Request a subscribed inbox for an agent, to be confirmed and paid for by its human owner
- `GET /api/v1/agents/subscriptions/{requestId}` - Check an agent subscription request, and collect the API key once it is active
- `GET /api/v1/agents/me` - Get the authenticated agent, including its inbox address
- `POST /api/v1/agents/register` - Register an agent and create its inbox (closed while paid plans are on sale)
- `GET /api/v1/emails/{address}/messages` - List messages for an owned inbox
- `GET /api/v1/emails/{address}/messages/{messageId}` - Get a message, including raw MIME
- `DELETE /api/v1/emails/{address}/messages/{messageId}` - Delete a message
- `GET /api/v1/emails/{address}/webhooks` - List inbox webhooks
- `POST /api/v1/emails/{address}/webhooks` - Create an inbox webhook
- `DELETE /api/v1/emails/{address}/webhooks/{webhookId}` - Delete an inbox webhook
- `POST /mcp` - Remote MCP server (Streamable HTTP) exposing inboxes as tools
- `GET /health` - Health check

### GET /api/api-keys

List human API keys

Authentication: BearerAuth (Authorization: Bearer <token>)

Responses:

- `200`: API keys

### POST /api/api-keys

Create a human API key

Authentication: BearerAuth (Authorization: Bearer <token>)

Responses:

- `201`: One-time API key
- `403`: The account has no active subscription, or already holds the number of keys its plan allows.

### POST /api/auth/login

Sign in to a human account

Responses:

- `200`: 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`: Invalid credentials
- `429`: Rate limited: 5 requests per minute per IP and per account. Retry after the number of seconds in the Retry-After header.

### POST /api/auth/register

Register a human account

Request body (application/json), required:

- `email` (string (email), required)
- `password` (string (length 12..), required)
- `name` (string)

Responses:

- `201`: 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`: Rate limited: 3 requests per minute per IP. Retry after the number of seconds in the Retry-After header.

### GET /api/emails

List human inboxes

Authentication: BearerAuth (Authorization: Bearer <token>)

Responses:

- `200`: Inboxes

### POST /api/emails

Create a human inbox

Authentication: BearerAuth (Authorization: Bearer <token>)

Responses:

- `201`: Inbox created
- `403`: The account has no active subscription, or already holds the number of inboxes its plan allows.

### PATCH /api/emails/{inboxId}

Rename, activate or deactivate an inbox

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.

Authentication: BearerAuth (Authorization: Bearer <token>)

Parameters:

- `inboxId` (path, string, required): The inbox id, or its current address.

Request body (application/json), required:

- `action` (string (one of: "rename") | string (one of: "activate", "deactivate"), required)
- `email_address` (string): The new address. Must be on the inbox domain.

Responses:

- `200`: Inbox updated
- `400`: Unknown action, or an address not on the inbox domain
- `401`: No valid session
- `404`: Inbox not found, or owned by another account
- `409`: That address is already taken

### GET /api/pricing

List purchasable plans

Responses:

- `200`: 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.

### GET /api/usage

Current usage against plan allowances

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.

Authentication: BearerAuth (Authorization: Bearer <token>)

Responses:

- `200`: Usage, allowances and any warnings
- `401`: Missing or invalid bearer token

### GET /api/v1/agents/challenge

Get a proof-of-work registration challenge

Responses:

- `200`: Challenge
- `429`: Rate limited: 10 requests per minute per IP. Retry after the number of seconds in the Retry-After header.

### POST /api/v1/agents/subscriptions

Request a subscribed inbox for an agent, to be confirmed and paid for by its human owner

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.

Request body (application/json), required:

- `handle` (string, required): 3-32 lowercase letters, digits or hyphens; becomes handle@agent.restapi.email
- `description` (string, required): 20-300 characters, shown to the owner
- `plan` (string (one of: "seed", "builder", "scale"), required)
- `billing_interval` (string (one of: "monthly", "yearly"; default "monthly"))
- `owner_email` (string (email), required): The human who will confirm and pay. Only an account signed in as this address can see or confirm the request.
- `idempotency_key` (string): Optional. Repeating a request with the same key, handle and owner_email returns the existing request instead of creating another.
- `pow_challenge` (string, required)
- `pow_nonce` (string, required)

Responses:

- `200`: An existing request matched the idempotency key; returned without the secret
- `201`: Pending request with request_id, request_secret (shown once), checkout_url for the owner and status_url to poll
- `400`: Invalid input or proof of work
- `409`: Handle already registered or requested
- `429`: Rate limited
- `503`: Subscriptions are not open

### GET /api/v1/agents/subscriptions/{requestId}

Check an agent subscription request, and collect the API key once it is active

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.

Authentication: BearerAuth (Authorization: Bearer <token>)

Parameters:

- `requestId` (path, string, required)

Responses:

- `200`: Request status; includes api_key exactly once after activation
- `401`: Missing or unknown request secret
- `404`: The secret does not belong to this request
- `429`: Rate limited

### GET /api/v1/agents/me

Get the authenticated agent, including its inbox address

Authentication: AgentKey (X-API-Key header)

Responses:

- `200`: Agent, including the inbox address mail should be sent to
- `401`: Missing or invalid X-API-Key

### POST /api/v1/agents/register

Register an agent and create its inbox (closed while paid plans are on sale)

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.

Request body (application/json), required:

- `handle` (string, required)
- `description` (string, required)
- `owner_contact` (string)
- `pow_challenge` (string, required)
- `pow_nonce` (string, required)

Responses:

- `201`: Agent and one-time API key
- `400`: Invalid registration
- `402`: Self-registration is closed while paid plans are on sale; the body names the subscription endpoint to use instead
- `409`: Handle already exists

### GET /api/v1/emails/{address}/messages

List messages for an owned inbox

Newest first. Also answers to a human account's sk_live_ API key for that account's inboxes.

Wait 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]`.

Authentication: AgentKey (X-API-Key header)

Parameters:

- `address` (path, string, required)
- `page` (query, integer (1..))
- `limit` (query, integer (1..100))
- `cursor` (query, string): 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.
- `q` (query, string): Full-text search across subject and body.
- `since` (query, string): 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.
- `wait` (query, integer (0..25; default 0)): 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.

Responses:

- `200`: Messages, newest first. List items carry metadata only; fetch a message for its body and `extracted` codes and links.
- `400`: Invalid since or wait
- `401`: Missing or invalid X-API-Key
- `403`: Inbox is not owned by this API key
- `429`: 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.

### GET /api/v1/emails/{address}/messages/{messageId}

Get a message, including raw MIME

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.

Authentication: AgentKey (X-API-Key header)

Responses:

- `200`: Message
  - `email` (object)
- `401`: Missing or invalid X-API-Key
- `404`: Message not found
- `429`: 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 /api/v1/emails/{address}/messages/{messageId}

Delete a message

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.

Authentication: AgentKey (X-API-Key header)

Responses:

- `200`: Deleted; the body carries the message id
- `401`: Missing or invalid X-API-Key
- `404`: Message not found, or already deleted

### GET /api/v1/emails/{address}/webhooks

List inbox webhooks

Authentication: AgentKey (X-API-Key header)

Responses:

- `200`: Webhooks
- `401`: Missing or invalid X-API-Key

### POST /api/v1/emails/{address}/webhooks

Create an inbox webhook

Authentication: AgentKey (X-API-Key header)

Request body (application/json), required:

- `url` (string (uri), required)
- `secret` (string)

Responses:

- `201`: Webhook and one-time secret
- `401`: Missing or invalid X-API-Key

### DELETE /api/v1/emails/{address}/webhooks/{webhookId}

Delete an inbox webhook

Authentication: AgentKey (X-API-Key header)

Responses:

- `200`: Deleted
- `401`: Missing or invalid X-API-Key
- `404`: Webhook not found

### POST /mcp

Remote MCP server (Streamable HTTP) exposing inboxes as tools

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_..."

Authentication: AgentKey (X-API-Key header) or BearerAuth (Authorization: Bearer <token>)

Request body (application/json), required:

- `jsonrpc` (string (one of: "2.0"), required)
- `id` (string | integer): Omitted for notifications.
- `method` (string, required): initialize, notifications/initialized, ping, tools/list or tools/call.
- `params` (object)

Responses:

- `200`: JSON-RPC response
- `202`: Notification accepted; no body
- `400`: Parse error, invalid request, batch, or unsupported MCP-Protocol-Version
- `401`: Missing or invalid API key; carries WWW-Authenticate: Bearer
- `403`: Browser Origin not allowed

### GET /health

Health check

Responses:

- `200`: Service healthy
