EternalMail

API reference

Everything in the dashboard is a plain HTTP call. Requests and responses are JSON, prices are in euros, and every timestamp is in milliseconds since the epoch. The base URL is the address of this site, so /api/v1/orders means https://your-host/api/v1/orders.

Your first call
curl https://YOUR-HOST/api/v1/me \
  -H "Authorization: Bearer em_live_…"

Authentication

Create a key in the dashboard under API, then send it as a bearer token. A key is shown once, so store it when you get it. Creating a new key replaces the old one.

Header
Authorization: Bearer em_live_9f2c…

Mailboxes can also be read without any account key. Send the mailbox password in an X-Mailbox-Password header together with the address, which is handy when you hand a single inbox to another program.

Prices and stock

GET/api/v1/products

Public. Returns the single product, how many mailboxes are in stock, the largest order, and the price tiers.

Response
{
  "products": [{
    "id": "eternal",
    "stock": 18420,
    "maxOrder": 50000,
    "currency": "EUR",
    "tiers": [{ "minQty": 1, "unitPrice": 0.011148 }, …]
  }]
}
GET/api/v1/quote?quantity=500

Public. The exact price of an order of that size, before you place it.

Buying

POST/api/v1/orders

Takes the price out of your balance and returns the order. Orders of 200 or fewer include the mailboxes in the response. Larger ones are fetched from the download endpoint below. Send an Idempotency-Key header so a retry after a timeout can never charge you twice: the same key returns the original order with "replay": true.

Request
POST /api/v1/orders
Authorization: Bearer em_live_9f2c…
Idempotency-Key: 3b7e-order-001

{ "quantity": 500, "style": "human" }
  • quantity: 1 up to the per-order maximum.
  • style: human for addresses like maya.reed82, or random for a 12 character string. Optional.
Response, status 201
{
  "order": { "id": 42, "quantity": 500, "unitPrice": 0.003902, "total": 1.951 },
  "balance": 18.049,
  "replay": false,
  "downloadUrl": "/api/v1/orders/42/mailboxes?format=txt&download=1"
}
GET/api/v1/orders

Your orders, newest first. Accepts limit (up to 200) and offset.

GET/api/v1/mailboxes

Every mailbox you own with its password and message count. Accepts limit (up to 1000), offset and order_id.

Download formats

GET/api/v1/orders/:id/mailboxes

Without parameters you get JSON. Add format to get a file, and download=1 to have the browser save it. You can fetch the same order as often as you like.

  • format=txt: one address:password per line. Change the separator with sep.
  • format=csv: a header row, then email,password.
  • format=json: an array of { email, password }.
  • sep: colon, tab, comma, semicolon, pipe, or one to three characters of your own. Text files only.
Save an order as a file
curl -H "Authorization: Bearer em_live_…" \
  "https://YOUR-HOST/api/v1/orders/42/mailboxes?format=txt&sep=pipe&download=1" \
  -o order-42.txt

Reading mail

These endpoints take the address in email. Use your API key for any mailbox you own, or the password header for any single mailbox.

GET/api/v1/mailbox/messages?email=…

Newest first. Accepts limit (up to 200), before_id and after_id for paging, and q to search. Each item includes the code and links found in the message.

GET/api/v1/mailbox/messages/:id?email=…

One message with its full text. Opening it marks it as read.

DELETE/api/v1/mailbox/messages/:id?email=…

Deletes the message for good.

A message in the list
{
  "id": 1,
  "from": "no-reply@example.com",
  "subject": "Your verification code is 482913",
  "code": "482913",
  "links": ["https://example.com/verify?token=abc123"],
  "read": false,
  "receivedAt": 1796116921750
}

Waiting for a code

GET/api/v1/mailbox/latest-code?email=…

Returns the newest verification code in the mailbox. If you pass a wait time, the request stays open until a message with a code arrives, so you do not have to poll.

  • wait: seconds to hold the request open, up to 60. Default 0.
  • fresh=1: ignore mail already in the box. Use it right after you trigger the email, so you never get an old code.
  • after_id: only consider messages newer than this id.
Trigger a login, then wait up to 30 seconds
GET /api/v1/mailbox/latest-code
    ?email=maya.reed82@…&wait=30&fresh=1

→ { "found": true, "code": "482913",
    "from": "no-reply@service.example",
    "links": ["https://…"] }

→ nothing arrived in time
  { "found": false }

Balance

POST/api/v1/payments

Starts a top-up. Send { "amount": 25 } in euros. The response contains an invoiceUrl where the customer chooses a coin and pays. The balance is credited by itself once the network confirms.

GET/api/v1/payments/:ref

Check one payment. When credited is true the money is in your balance.

GET/api/v1/me

Your account and current balance in euros.

GET/api/v1/ledger

Every change to your balance, with the balance after it.

Webhooks

Set a public https address in the dashboard, or with PUT /api/v1/webhook and { "url": "…" }. We POST every message that lands in any mailbox you own. The signing secret is returned with the webhook.

What we send
X-EternalMail-Event: message.received
X-EternalMail-Timestamp: 1796116921
X-EternalMail-Signature: sha256=9c1d…

{
  "type": "message.received",
  "created": 1796116921,
  "data": {
    "mailbox": "maya.reed82@…",
    "message": { "id": 1, "subject": "…", "code": "482913" }
  }
}

Verify the signature

The signature is an HMAC-SHA256 of the timestamp, a dot, and the raw request body, keyed with your secret. Compute it yourself and compare it in constant time. Reject requests whose timestamp is more than a few minutes old.

Node.js
import crypto from 'node:crypto';

const expected = 'sha256=' + crypto
  .createHmac('sha256', secret)
  .update(`${timestamp}.${rawBody}`)
  .digest('hex');

const ok = crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature));

Answer with any 2xx status within eight seconds. Anything else is retried, up to four attempts in total with growing gaps, and every attempt appears in the delivery log in your dashboard.

Errors and limits

Errors use the same shape everywhere: { "error": { "code", "message" } }. Branch on code, not on the message text.

Not enough balance, status 402
{
  "error": {
    "code": "insufficient_balance",
    "message": "Your balance is too low for this order",
    "required": 1.951, "balance": 1.2, "missing": 0.751
  }
}
  • 400 a bad parameter, such as a quantity above the maximum.
  • 401 a missing or wrong key or mailbox password.
  • 402 insufficient_balance. Top up and try again.
  • 409 out_of_stock. The response says how many are left in available.
  • 429 too many requests. The API allows 600 a minute per account, and orders are capped at 60 a minute.

Mail is receive-only. There is no sending endpoint, no IMAP and no POP3.