Mail.cx
v1REST · Long-Poll · SSE

Temporary Email API

Zero-setup disposable email API built for AI agents, E2E signup tests, and custom-domain catch-all workflows. No mailbox creation step — mail buffers the instant SMTP accepts it.

Base URL
https://api.mail.cx/v1
Authentication
x-api-token: tm_live_...
Access & Rate Limit
Pro plan · 10 req/s · 72h TTL

Quickstart

Mint keys in Dashboard → Tokens
# 1. Discover available system domains (requires Pro API token on api.mail.cx)
TOKEN="tm_live_your_api_key"
curl -s "https://api.mail.cx/v1/config" -H "x-api-token: $TOKEN"

# 2. Pick any valid address — mailboxes are implicit (no create call needed)
ADDR="agent-test-01@uqu.me"

# 3. Wait up to 25 s for a matching message (returns 200 immediately on arrival, 204 on timeout)
curl -s "https://api.mail.cx/v1/inbox/$ADDR?subject=Verify" \
  -H "x-api-token: $TOKEN"

# 4. Fetch the full parsed email (text_body, html_body, attachments)
curl -s "https://api.mail.cx/v1/email/<id>" \
  -H "x-api-token: $TOKEN"

# Optional: pass ?wait=0 for an instant non-blocking snapshot
curl -s "https://api.mail.cx/v1/inbox/$ADDR?wait=0" \
  -H "x-api-token: $TOKEN"

Endpoints

Mailboxes & Messages

Mailboxes are implicit — send mail to any valid local-part on a system or verified custom domain and read it directly.

GET/v1/config

List active system domains (including Pro-only domains) and local-part validation rules.

GET/v1/inbox/:address

Long-poll (default 25 s) or instant snapshot (?wait=0) for a single email address.

DELETE/v1/inbox/:address

Delete all messages currently stored at the address.

GET/v1/email/:id

Fetch full parsed message: headers, text_body, html_body, and attachment metadata.

GET/v1/email/:id/raw

Stream the original RFC 822 .eml message.

GET/v1/email/:id/attachments/:index

Download a binary attachment by zero-based index.

DELETE/v1/email/:id

Permanently delete a single message (204 No Content).

Catch-All & Real-Time Streams

Cross-address feeds (/v1/domain/:domain, /v1/me, /v1/sse/user) stream mail delivered to your verified custom domains.

GET/v1/domain/:domain

Catch-all long-poll (or ?wait=0 snapshot) across every address under your custom domain.

GET/v1/me

Unified long-poll across all verified custom domains on your account (includes `to` & `created_at`).

GET/v1/sse/addr?address=&token=

Server-Sent Events push stream for a single address (`event: email`).

GET/v1/sse/user?token=

Server-Sent Events push stream across all owned custom domains.

Custom Domains & API Keys

POST/v1/domains

Register a custom domain (`{"domain":"mail.example.com"}`); returns TXT & MX records.

GET/v1/domains

List custom domains with `verify_status` (`pending`, `verified`, `failed`) and `mx_configured`.

DELETE/v1/domains/:id

Remove a custom domain and purge its routing entry.

POST/v1/tokens

Mint a new `tm_live_...` API key (`{"name":"ci-suite"}`); plaintext returned once.

GET/v1/tokens

List active API keys (prefix, name, created_at, last_used_at).

DELETE/v1/tokens/:id

Immediately revoke an API key.

Long-Polling & Query Parameters

/v1/inbox/:address, /v1/domain/:domain, and /v1/me share one unified query interface. By default, requests hold for up to 25 seconds and wake up within milliseconds via NATS as soon as matching mail lands — eliminating client polling loops. Pass ?wait=0 whenever you want an immediate non-blocking snapshot instead.

ParamDefaultDescription
wait25Hold time in seconds (0–25). Default 25 blocks until mail arrives (200) or returns 204 after 25 s. Pass ?wait=0 for an immediate non-blocking 200 snapshot.
since""Opaque cursor from the previous response’s next_since; returns strictly newer messages.
count1Return early only once at least N matching messages have arrived (1–50).
limit20Maximum number of messages returned in a single response (1–50).
from—Case-insensitive substring match against the From header.
subject—Case-insensitive substring match against the Subject header.
List / Long-Poll Response (200 OK)
{
  "emails": [
    {
      "id": "019670a4f2c8...",
      "to": "agent@uqu.me",
      "from_name": "GitHub",
      "from_email": "noreply@github.com",
      "subject": "Your verification code",
      "preview_text": "Use 842910 to verify...",
      "size": 4182,
      "created_at": "2026-11-26T05:30:12Z"
    }
  ],
  "next_since": "1795671012"
}
Message Detail (GET /v1/email/:id)
{
  "id": "019670a4f2c8...",
  "from": "GitHub <noreply@github.com>",
  "from_name": "GitHub",
  "from_email": "noreply@github.com",
  "to": "agent@uqu.me",
  "subject": "Your verification code",
  "text_body": "Use 842910 to verify...",
  "html_body": "<p>Use <b>842910</b>...</p>",
  "attachments": [
    { "index": 0, "filename": "invite.ics", "content_type": "text/calendar", "size": 912 }
  ],
  "created_at": "2026-11-26T05:30:12Z"
}

Custom Domain DNS Setup

Connect up to 100 custom domains via POST /v1/domains or the web dashboard, then publish two DNS records:

TXT _tempmail.<domain> tempmail-verify=<token>
MX <domain> 10 smtp.mail.cx

Background verification runs every 5 minutes; unverified domains expire after 72 hours.

Throughput & Retention

  • 10 requests / second sliding-window per API key (no daily or monthly request cap).
  • Concurrency: 1 active long-poll wait per API token (use /v1/me or /v1/domain/:domain to watch unlimited addresses over one connection); up to 10 concurrent waits per address.
  • Retention: Pro messages stay readable for 72 hours before automatic Redis + blob purge.

Status & Error Codes

All errors return {"error": "<code>"} with standard HTTP status codes (Retry-After is included on 429 responses).

HTTPError Code(s)Meaning
400invalid_address · invalid domain formatMalformed address, invalid domain syntax, or negative attachment index.
401authentication_required · invalid_tokenMissing, revoked, or malformed x-api-token header.
403plan_required · quota_exceeded · account_disabledActive Pro plan required for api.mail.cx, or domain/token cap (100) reached.
404not_found · domain_not_found · attachment_not_foundMessage expired/missing, or domain is unverified / owned by another account.
409domain_already_existsCustom domain is already registered.
410email_expiredMessage body TTL expired before download.
429rate_limit_exceeded · token_busy · addr_busyExceeded 10 req/s per token, 1 concurrent long-poll per token, or 10 per address.
503sse_unavailableReal-time broker temporarily unavailable; retry with backoff.