Build with your inbox.
A versioned REST API for permanent monitored addresses, message retrieval, attachments, incremental events, and signed webhooks.
https://website2zip.com/temp-mail/admin/api/v1From zero to a working inbox through the API.
Use the administrator password through POST /auth/login, or a management API key. There is no public account registration. The complete setup guide and Python setup client cover authentication, domain discovery and connection, new email addresses, and scoped API keys.
- Call
POST /auth/loginwith{"password":"YOUR_ADMIN_PASSWORD"}and the canonical Origin header. Retain the secure cookie and returned CSRF token in memory. - Call
GET /domainsto see ready domains, orGET /domains/discoverfor owned Cloudflare zones. - For a new domain, call
POST /domains/preview, inspect the DNS changes and next steps, thenPOST /domainswith its signed plan. - Call
POST /mailboxes/previewwith your new email address, thenPOST /mailboxeswith the plan and an Idempotency-Key. - Call
POST /keysthrough the administrator session to issue a scoped key. Use it for messages, attachments, events, and webhooks. - Call
POST /auth/logoutwhen provisioning finishes.
export W2Z_ADMIN_PASSWORD="YOUR_ADMIN_PASSWORD"
python setup_client.py domains
python setup_client.py discover-domains
python setup_client.py create-inbox [email protected] --operation-id my-inbox-001
python setup_client.py create-key --name invoice-reader --scopes mailboxes:read,messages:read --mailboxes MAILBOX_IDCookie mutations require Origin: https://website2zip.com and X-CSRF-Token. The setup client handles both and signs out automatically. API keys use Bearer authentication and do not need cookies or CSRF tokens.
Connect an owned email domain.
GET /domains returns ready receiving domains with available, can_create, and public_temporary_available. New domains connected through this API are private; they are not added to the public temporary-mail pool.
| Endpoint | Purpose |
|---|---|
GET /domains/discover | List zones in the configured Cloudflare account. |
GET /domains/status?domain={domain} | Check live DNS, routing, nameservers, conflicts, and next actions. |
POST /domains/preview | Review setup and obtain a ten-minute signed plan. |
POST /domains | Connect the domain, optionally add its zone and enable Email Routing. |
POST /domains/verify | Refresh a connected domain after propagation. |
POST /domains/preview
{"domain":"your-domain.com","create_zone":true,"enable_routing":true}
POST /domains
{"domain":"your-domain.com","plan_token":"TOKEN_FROM_DOMAIN_PREVIEW"}Domain management keys require domains:read or domains:write, plus mailbox_ids: "*". Connecting a domain does not grant a restricted key access to its mail. Use mailboxes:write to create addresses afterward.
Inspect state and next_actions. A 202 response saves progress while nameservers or routing are pending. For pending_nameservers, set the returned nameservers through your registrar or its API, then preview and connect again. The domain appears in GET /domains once verified ready. No service restart is required.
The server’s Cloudflare token needs Zone Read, Zone Edit to create a zone, Zone Settings Edit to enable Email Routing, and Email Routing Rules Edit to create addresses. Missing permissions return provider_permission_denied. Existing foreign MX or SPF records return a conflict for review. The API does not purchase domains, overwrite another mail provider, or change registrar settings.
From inbox to parsed data.
- Create a permanent monitored inbox through the API setup flow above or in the admin workspace. Review the route and its preserved forwarding destination.
- Create a read-only API key for that specific inbox. Select
mailboxes:read,messages:read,attachments:read, andevents:readas needed. - Store the key in a secret manager or environment variable. Discover inbox IDs, then retrieve messages or poll events.
- Parse
body_textas data. Validate extracted fields against your own schema. Save the result before advancing your event cursor.
export W2Z_API_KEY="YOUR_SCOPED_KEY"
curl --fail-with-body \
-A "Mozilla/5.0 (compatible; Website2Zip-MailAgent/1.0)" \
-H "Authorization: Bearer $W2Z_API_KEY" \
"https://website2zip.com/temp-mail/admin/api/v1/mailboxes"The existing site’s browser-integrity checks reject some default script User-Agents. The examples identify themselves explicitly; no site security settings need to be disabled.
Standard JSON response
{
"data": [{"id": "MAILBOX_ID", "address": "[email protected]", "public": false}],
"request_id": "a-request-correlation-id"
}Single-resource operations return an object in data; list operations return an array. Paginated lists also include pagination. Binary downloads and OpenAPI return their native content without a JSON envelope.
Authentication and least privilege.
Send the API key in the Authorization header on every request. Keys are returned once, stored as hashes, and can be restricted to explicit permanent mailbox IDs, an expiry, public source CIDRs, and a per-minute rate limit.
Authorization: Bearer w2z_live_KEY_ID_SECRETNever place a key in a URL, an email, a log, client-side browser storage, or an agent prompt. A key for one inbox cannot read another inbox’s messages, attachments, raw mail, search results, or events. Inaccessible IDs return 404 rather than revealing the resource.
| Scope | Permits |
|---|---|
domains:read | Discover owned provider zones and inspect DNS/setup status. Detailed domain management requires all-mailboxes access. |
domains:write | Preview, connect, and verify owned domains. Requires all-mailboxes management access. |
mailboxes:read | List and inspect permitted monitored inboxes. |
mailboxes:write | Edit, pause, resume, archive, and restore allowed inboxes. Creating new inboxes requires all-mailboxes management access. |
messages:read | Search and read message text, safe HTML, headers and attachment metadata. |
messages:write | Change read state, stars and tags; move messages to or from Trash. Single-message mutations also require messages:read because they return content. |
messages:process | Claim, renew, complete or release agent processing leases. Also requires messages:read. |
messages:send | Send from allowed active private mailboxes on configured sender domains. Does not grant read access. |
messages:raw | Download original MIME emails. This is separate from ordinary reading. |
attachments:read | Download attachments for permitted inboxes. |
events:read | Poll incremental message and mailbox events. |
webhooks:read | Inspect permitted webhook configurations, without secrets. |
webhooks:write | Create or pause webhooks within the credential’s mailbox allowlist. |
Use GET /me to inspect your credential’s current scopes and mailbox allowlist. Revocation takes effect on the next request. API keys cannot manage other API keys, read the owner audit log, change owner security, or create browser sessions.
Owner browser sessions
The admin uses a Secure, HttpOnly, SameSite=Strict __Host-w2z_monitor cookie. Session mutations require Origin: https://website2zip.com and the X-CSRF-Token returned by GET /auth/session. Bearer-authenticated requests do not use cookies or CSRF tokens.
GET /domains lists the receiving domains visible to the credential. Only all-mailboxes management keys can create new inboxes; restricted keys see only domains of their allowed inboxes.
Permanent monitored addresses.
Use any supported custom local part on an available owned domain, such as [email protected]. The complete address must be at most 90 characters under Cloudflare’s routing limit. Quoted local parts and SMTPUTF8 addresses are not supported. External Gmail/IMAP accounts and historical mail in external mailboxes are not imported.
/mailboxesList permitted inboxes/mailboxes/previewRead-only routing review{"address": "[email protected]"}The preview returns plan_token, forward_to, and expires_at. It expires in ten minutes. Creating a mailbox rechecks the existing route and rejects a stale plan. It preserves verified forwarding destinations and never edits a catch-all rule or MX record. Existing custom Worker routes and ambiguous duplicate rules are rejected rather than overwritten.
/mailboxesCreate after routing reviewIdempotency-Key: a-unique-operation-id
{
"address": "[email protected]",
"plan_token": "TOKEN_FROM_PREVIEW",
"label": "Invoice parsing",
"retention_days": 0,
"max_bytes": 536870912
}retention_days: 0 keeps messages until deleted. A permanent address does not expire after 24 hours. Retention may be set from 1 to 3650 days; maintenance removes older content about once per minute. Lowering retention can remove old messages, so review the change carefully.
| Operation | Behavior |
|---|---|
GET /mailboxes/{id} | Read state, forwarding, retention, storage and counts. |
PATCH /mailboxes/{id} | Change label, notes, retention or storage quota. |
POST /mailboxes/{id}/pause | Stop storing new messages; continue existing forwarding. |
POST /mailboxes/{id}/resume | Resume a paused monitor. |
POST /mailboxes/{id}/archive | Restore the original route; keep private stored content. |
POST /mailboxes/{id}/restore-preview | Review current routing for an archived monitor. |
POST /mailboxes/{id}/reconcile | Recover interrupted provisioning without replacing a changed route. |
POST /mailboxes/{id}/restore | Restore using the new plan_token. |
Action endpoints accept {} as their JSON body. An archive operation refuses to overwrite a route changed outside the tool. Use Recover routing, or POST /mailboxes/{id}/reconcile, after an interrupted operation. Recovery preserves whether you were creating, restoring, or archiving monitoring. A changed foreign route still requires manual review.
Read and search messages.
/messagesNewest-first, cursor-paginatedGET /messages?mailbox_id=MAILBOX_ID&unread=true&limit=50
GET /messages?mailbox_id=MAILBOX_ID&q=invoice&has_attachments=true
GET /messages?received_after=2026-11-08T00%3A00%3A00ZSupported filters: mailbox_id, q, from, subject, unread, starred, has_attachments, folder (inbox, trash, all), received_after, and received_before. Boolean query values are true or false. Timestamps require a timezone and are returned in UTC.
{
"data": [{"id": "MESSAGE_ID", "mailbox_id": "MAILBOX_ID", "subject": "Invoice"}],
"pagination": {"limit": 50, "has_more": true, "next_cursor": "OPAQUE_CURSOR"},
"request_id": "..."
}Follow next_cursor until has_more is false. Keep the same filters, page size and credential. Cursors expire after one hour. Page sizes range from 1 to 100. New incoming messages do not reorder the cursor’s already visited position.
/messages/{id}Full content and attachment metadata{
"data": {
"id": "MESSAGE_ID",
"mailbox_id": "MAILBOX_ID",
"sender": "Supplier <[email protected]>",
"subject": "Invoice 1042",
"received_at": "2026-11-08T12:30:00Z",
"body_text": "Your invoice total is ...",
"body_html": "<p>Your invoice total is ...</p>",
"headers": {"message-id": "<[email protected]>"},
"attachments": [{"id": "ATTACHMENT_ID", "filename": "invoice.pdf", "size": 24000}],
"is_read": false,
"starred": false,
"tags": []
},
"request_id": "..."
}A GET never marks mail as read. After your program successfully saves its result, optionally use PATCH /messages/{id} with {"is_read": true, "tags": ["processed"]}. messages:write is required.
Move to Trash with DELETE /messages/{id} or PATCH {"trashed": true}. Restore with PATCH {"trashed": false}. Trash is recoverable for 30 days unless mailbox retention removes it earlier. Bulk actions accept 1–100 IDs via POST /messages/bulk; access is validated for every ID before any update.
Send email through the API.
Use GET /sending to inspect your permitted sender mailboxes and local configuration. Create a key with messages:send for the private mailboxes it may send from. Existing keys do not gain this permission automatically. Sending requires an active private mailbox and a domain enabled with the configured outbound provider.
/sendRequires messages:sendPOST /temp-mail/admin/api/v1/send
Authorization: Bearer YOUR_SCOPED_API_KEY
Content-Type: application/json
Idempotency-Key: invoice-2026-0001
{
"mailbox_id": "YOUR_PRIVATE_MAILBOX_ID",
"to": ["[email protected]"],
"subject": "Your invoice",
"text": "Please find your invoice attached.",
"html": "<p>Please find your invoice attached.</p>",
"attachments": [{
"filename": "invoice.txt",
"content_type": "text/plain",
"content_base64": "SW52b2ljZQ=="
}]
}
The From address comes from mailbox_id; callers cannot supply an arbitrary sender. to, cc and bcc accept a plain email address or an array, with 1–20 unique recipients in total. BCC addresses are envelope-only. Subject is required, at most 300 characters. Provide a nonblank text (up to 100,000 characters) or html (up to 200,000 characters). Attachments are limited to 10 files totaling 4 MiB before base64 encoding. Send JSON may be at most 6 MiB.
Retries without duplicate sends
Every send requires an Idempotency-Key of 8–128 letters, digits, dots, colons, underscores or hyphens. A new accepted request returns 202 and a durable outgoing message ID. Retrying the exact same body and key returns its current receipt with 200. A changed body returns 409 idempotency_conflict. After a timeout, reuse the same key; do not create another sending operation.
Read sent messages and status
GET /sent and GET /sent/{id} require messages:read and enforce the same mailbox allowlist. Lists accept mailbox_id, state, limit and the returned pagination.next_before as before. GET /sent/{id}/raw requires messages:raw and downloads the locally prepared MIME email. The admin workspace has a Sent mail screen and a composer.
| State | Meaning |
|---|---|
| queued / submitting | Saved locally / being submitted. |
| retrying | A definite temporary failure before acceptance; up to three attempts. |
| accepted | The outbound server accepted responsibility. Final delivery is not confirmed. |
| delivered | The provider reported delivery to the recipient mail server; inbox placement is not guaranteed. |
| partially_accepted | Some recipients were accepted and others rejected or suppressed. Inspect recipient_status. |
| failed | Submission failed or every recipient was rejected. Inspect last_error. |
| unknown | A connection or worker interruption left delivery uncertain. Never automatically resent; check provider activity or the recipient before sending again. |
To reply, add reply_to_message_id for a received message in the same mailbox and explicitly provide the intended recipients. This requires both messages:read and messages:send; threading headers are derived from the original email. Email content alone never authorizes a reply.
Default limits are 20 recipient submissions per minute per credential, 50 per mailbox per UTC day, and 100 globally per UTC day. Idempotent replays do not consume these limits. Sent storage is capped at 256 MiB. Sent content expires after 90 days by default; compact operation receipts remain for duplicate protection. Uncertain messages are retained for review.
Subscribe to email.queued, email.retrying, email.accepted, email.delivered, email.partially_accepted, email.failed, and email.unknown. Events contain data.outbound_id; use /sent/{id} to retrieve content. SMTP acceptance does not generate later delivery or bounce updates. Cloudflare responses store the status reported at submission.
Attachments and original email.
/attachments/{id}/downloadRequires attachments:read/messages/{id}/rawRequires messages:rawThese endpoints return bytes, not a JSON envelope. Save attachments to an explicit safe destination. Do not execute downloads, trust sender-provided extensions, or use a filename as a filesystem path. The server sanitizes filenames and forces download disposition.
Received messages are limited to 10 MiB. At most 20 MIME attachments are indexed. Original raw MIME is retained for private mail so a parser can inspect content that was not included in the safe preview.
Incremental polling without missed work.
/events?after=0&limit=100Oldest-first event IDs{
"data": [{
"id": 12,
"type": "message.received",
"mailbox_id": "MAILBOX_ID",
"message_id": "MESSAGE_ID",
"created_at": "2026-11-08T12:30:00Z",
"data": {"subject": "Invoice 1042", "attachment_count": 1}
}],
"pagination": {"limit": 100, "has_more": false, "next_after": 12},
"request_id": "..."
}- Read events after your durable saved event ID. Optionally filter by an allowed
mailbox_id. - For each
message.receivedevent, fetch the full message using its ID. - Validate and save your parsed result using message ID as an idempotency key.
- Persist
next_afteronly after processing the batch successfully. - If
has_moreis true, fetch the next batch immediately. Otherwise wait 5–15 seconds.
Delivery and polling are at least once. Always deduplicate by event ID or message ID. The event feed intentionally omits full bodies and attachment bytes.
Coordinate multiple agents.
Processing leases are optional. They let one agent claim a message while other agents skip it. Read state and processing state are independent. Use messages:read and messages:process on a key limited to the required inboxes.
POST /messages/MESSAGE_ID/claim
{"lease_seconds":120}
POST /messages/MESSAGE_ID/claim/renew
{"lease_token":"ONE_TIME_LEASE_TOKEN","lease_seconds":120}
POST /messages/MESSAGE_ID/claim/complete
{"lease_token":"ONE_TIME_LEASE_TOKEN","result":{"record_id":"invoice-1042"}}
POST /messages/MESSAGE_ID/claim/release
{"lease_token":"ONE_TIME_LEASE_TOKEN"}The claim response includes a secret lease_token, returned once. Keep it in memory. Leases last 30–900 seconds, default 120, and belong to the same API credential plus that token. Renew before expiry when work takes longer. A lost or expired lease returns 409 lease_lost; stop and reconcile before committing more effects. A crashed worker's lease expires so another agent can recover it.
Filter pending work with GET /messages?processing_status=available. Other values are processing and completed. Active claims return 409 message_claimed; completed messages return 409 already_processed. A timeout can leave a claim until expiry. Claims prevent simultaneous processing, but external writes still need idempotency using the message ID.
Complete only after saving your business result. Optional result is a JSON object of at most 16 KiB. It is private and visible to credentials allowed to read the email. Completion emits message.processed. If completion times out, retrieve the message and inspect processing.state and processing.result before retrying. The owner can reset processing from the reader; that clears the saved processing result and makes the email available again.
lease = client.claim(message_id)
message = client.read(message_id)
# Extract and validate data. Save it idempotently using message_id.
# Renew with client.renew(...) before the lease expires if needed.
client.complete(message_id, lease["lease_token"], {"record_id": saved_record_id})Signed webhook delivery.
Add an HTTPS endpoint in the workspace or via POST /webhooks. Select explicit mailbox IDs and event types. The signing secret is returned once. Webhooks send event metadata, not full email bodies or your API credentials.
{
"name": "Invoice automation",
"url": "https://your-app.example/hooks/mail",
"mailbox_ids": ["MAILBOX_ID"],
"event_types": ["message.received"]
}Verify before parsing
X-W2Z-Event-ID: 12
X-W2Z-Delivery-ID: DELIVERY_ID
X-W2Z-Signature: t=1794141000,v1=HEX_HMAC
signed_bytes = timestamp_utf8 + b"." + exact_raw_request_body
expected = HMAC_SHA256(signing_secret_utf8, signed_bytes).hexdigest()Reject timestamps more than five minutes from your clock. Use a constant-time signature comparison. Deduplicate the event ID, persist the work durably, then acknowledge with a 2xx response. Re-encoding the JSON before verification changes its bytes and invalidates the signature.
import hashlib, hmac, time
def verify_webhook(raw_body, signature_header, secret):
parts = dict(item.split("=", 1) for item in signature_header.split(","))
timestamp = int(parts["t"])
if abs(time.time() - timestamp) > 300:
raise ValueError("stale timestamp")
signed = str(timestamp).encode() + b"." + raw_body
expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
if not hmac.compare_digest(expected, parts["v1"]):
raise ValueError("invalid signature")The delivery ID and event payload stay stable across attempts; timestamps and signatures are refreshed. Up to eight attempts use capped exponential backoff starting at 30 seconds. A dedicated worker checks due deliveries about every ten seconds. Redirects are failures. Dead-lettered attempts remain visible and can be retried by the owner.
Only public HTTPS destinations on port 443 are allowed. Every attempt revalidates DNS, rejects non-public addresses, pins a validated public IP, and verifies the TLS hostname. This prevents private-network access and DNS-rebinding redirects.
Delivery is at least once. In-flight sends have a five-minute recovery lock. The pending queue is capped at 10,000; if it fills, messages and events remain readable through the API while additional notifications are skipped. Workspace statistics report the cumulative skipped count. Poll events to recover missed notifications. Quota alerts are coalesced to one per inbox per 15 minutes.
Errors, rate limits and retries.
{
"error": {"code": "insufficient_scope", "message": "This credential requires the messages:read scope."},
"request_id": "REQUEST_ID"
}| Status | What your agent should do |
|---|---|
| 400 / 415 | Correct validation, parameter or JSON content-type errors before retrying. |
| 401 | Stop. The key or session is missing, expired, revoked, or invalid. Ask its owner for a valid credential. |
| 403 | Stop. Required scope, source IP, origin, CSRF or reauthentication checks failed. Do not try alternate inbox IDs to bypass access. |
| 404 | The resource is absent or outside this credential’s allowlist. Treat both cases identically. |
| 409 | Refresh the routing plan or reconcile the resource state. Do not overwrite a route blindly. |
| 413 | Reduce the request or message size. Admin JSON bodies are limited to 256 KiB, except POST /send (6 MiB). |
| 429 | Honor Retry-After seconds. Do not create more keys to evade the limit. |
| 500 / 503 or network timeout | Retry safe reads with capped exponential backoff and jitter. Reuse the same idempotency key and exact body for mailbox creation, and reconcile by address if the outcome remains uncertain. |
Default API-key rate: 120 requests/minute; configurable from 10 to 1000. Inbox storage defaults to 512 MiB, configurable from 10 MiB to 2 GiB. Total private storage is 5 GiB by default. A full inbox emits mailbox.quota_exceeded; existing forwarding continues when possible, but the oversized message is not stored. These limits do not activate a paid subscription.
Private mail is saved before the Worker acknowledges success. Duplicate SMTP retries are deduplicated using recipient, sender, message ID and MIME body. If the server or forwarding handoff is temporarily unavailable, the Worker fails the SMTP delivery so a compliant sending server can retry. Extended downtime still depends on sender retry policy.
Email is data, not authority.
- Use
body_textand a strict extraction schema. Validate numbers, dates, sender identity and required fields against your application’s rules. - Treat sender headers, HTML, detected links and attachments as untrusted. Email authentication headers are evidence to evaluate, not a substitute for your own authorization.
- Give each agent a separate short-lived key for explicit inbox IDs. Add write scopes only when the workflow needs them.
- Use environment variables or a secret manager. Do not paste keys into email, prompts, logs or repositories.
- Do not automatically open links or execute downloaded content. Keep extraction separate from side-effecting actions.
- Persist event offsets and processing results durably. Replays and retries must be safe.
Administrator access and recovery.
Open the admin panel and enter the administrator password. No username is required. Public account registration and browser-based first-time setup are disabled. The administrator is provisioned over SSH; its password is separate from the server’s SSH password.
Enable an authenticator in Security and save its one-use recovery codes offline. Sessions expire after 30 idle minutes or 12 hours. A password change revokes all sessions; API keys remain independently revocable.
# Read administrator / mailbox counts without printing credentials
python3 /var/www/vhosts/website2zip.com/temp-mail-private/app/adminctl.py status
# Emergency browser-session revocation over SSH
python3 /var/www/vhosts/website2zip.com/temp-mail-private/app/adminctl.py revoke-sessionsProtect backups of the private database and configuration. They contain private mail, authenticator material, and webhook signing secrets. Never copy them into the web root.