A disposable e-mail API for CI: create inboxes, wait for mail and check your transactional e-mails
Use a disposable e-mail API in CI: create an inbox with curl, wait for the next message, verify signed webhooks and check links, SPF, DKIM and DMARC.

Some pipelines need to read e-mail: a smoke test after a deploy that signs up a user, a nightly job that checks the invite mail still renders, a contract test for a webhook that sends a receipt. Public throwaway inbox sites are shared, rate limited and not built for scripts. A disposable e-mail API gives each job its own private address and an endpoint that returns when the message arrives.
This guide uses the OTPBox REST API with curl and jq, so it works in any CI system. OTPBox is receive-only, stores messages encrypted per account, and is part of the rc.center Pro plan.
Authentication
Create an API key in the OTPBox web app (Inboxes page, API keys). Keys are created only there, by a person, and shown once. Store it as a CI secret and pass it as a bearer token:
export OTPBOX_KEY='<your-api-key>'
curl -s https://otpbox.rc.center/v1/usage -H "Authorization: Bearer $OTPBOX_KEY"
{
"plan": "pro",
"receiving": true,
"inboxes": { "used": 2, "limit": 20, "remaining": 18, "percent": 10 },
"messages_this_month": { "used": 41, "limit": 1000, "remaining": 959, "percent": 4.1 },
"messages_last_minute": { "used": 0, "limit": 30, "remaining": 30, "percent": 0 },
"max_message_bytes": 10485760,
"retention_days": 30
}
(The response also includes stored bytes against the storage limit; shortened here.)
The five calls you will use
Create an inbox. The body is optional; prefix makes the address readable in logs.
curl -s -X POST https://otpbox.rc.center/v1/inboxes \
-H "Authorization: Bearer $OTPBOX_KEY" \
-H 'Content-Type: application/json' \
-d '{"prefix":"ci-smoke"}'
{
"id": "<inbox-id>",
"address": "ci-smoke.pr3xh8@<account>.otpbox.org",
"domain": "otpbox.org",
"created_at": "2026-10-20T18:20:37Z"
}
Every account receives on its own random subdomain, and every address has a random part. Addresses on otpbox.top are also available: pass "domain":"otpbox.top" when a site refuses one of the two. A +tag after the local part still reaches the same inbox.
Wait for the next message. This is a long poll: it returns as soon as a matching message is processed, or after timeout seconds (1 to 120, default 30).
curl -s "https://otpbox.rc.center/v1/inboxes/<inbox-id>/wait?timeout=60&expect_domain=example.com&subject=welcome" \
-H "Authorization: Bearer $OTPBOX_KEY"
The filters are expect_domain (sender domain or verify link domain), from_domain, from (a substring of the sender address, never the display name), subject, regex (RE2, matched against subject and text) and since (RFC 3339). Without since it also returns matching messages from the last 10 minutes. On timeout the answer is {"found": false} with status 200.
List the messages of an inbox, newest first (limit up to 200, optional since):
curl -s "https://otpbox.rc.center/v1/inboxes/<inbox-id>/messages?limit=20" \
-H "Authorization: Bearer $OTPBOX_KEY"
Get one message in full: headers, text, code candidates, classified links, attachments, SMTP envelope and the SPF, DKIM and DMARC results. Add html=1 for the sanitized HTML body.
curl -s https://otpbox.rc.center/v1/messages/<message-id> \
-H "Authorization: Bearer $OTPBOX_KEY"
Delete the inbox when the job is done. The address stops receiving and is never reused.
curl -s -X DELETE https://otpbox.rc.center/v1/inboxes/<inbox-id> \
-H "Authorization: Bearer $OTPBOX_KEY"
A shell script for any CI system
This script creates an inbox, runs a command that should send mail to it, waits, and fails the job if the mail does not arrive or is not authenticated.
#!/usr/bin/env bash
# ci-mail-check.sh: fail the job unless the app sends an authenticated e-mail.
set -euo pipefail
API=https://otpbox.rc.center/v1
AUTH="Authorization: Bearer $OTPBOX_KEY"
inbox=$(curl -sf -X POST "$API/inboxes" -H "$AUTH" -H 'Content-Type: application/json' -d '{"prefix":"ci"}')
inbox_id=$(echo "$inbox" | jq -r .id)
address=$(echo "$inbox" | jq -r .address)
trap 'curl -sf -X DELETE "$API/inboxes/$inbox_id" -H "$AUTH" > /dev/null' EXIT
# Trigger the e-mail (replace with your own sign-up, invite or receipt call).
curl -sf -X POST https://staging.example.com/api/invite \
-H 'Content-Type: application/json' -d "{\"email\":\"$address\"}"
mail=$(curl -sf "$API/inboxes/$inbox_id/wait?timeout=90&expect_domain=example.com" -H "$AUTH")
[ "$(echo "$mail" | jq -r .found)" = "true" ] || { echo "no e-mail within 90 s"; exit 1; }
[ "$(echo "$mail" | jq -r .sender_auth)" = "pass" ] || { echo "sender authentication: $(echo "$mail" | jq -c .message.auth)"; exit 1; }
echo "received: $(echo "$mail" | jq -r .message.subject)"
echo "link host: $(echo "$mail" | jq -r .verify_link_host)"
trap deletes the inbox even when a check fails, which keeps aborted runs from filling the active inbox limit.
Push instead of poll: signed webhooks
If a job should react to mail rather than wait for it, set a webhook on the inbox. OTPBox then POSTs an event for every new message. The URL must be https and must not point at a private address.
curl -s -X PUT https://otpbox.rc.center/v1/inboxes/<inbox-id>/webhook \
-H "Authorization: Bearer $OTPBOX_KEY" \
-H 'Content-Type: application/json' \
-d '{"url":"https://hooks.example.com/otpbox"}'
{
"url": "https://hooks.example.com/otpbox",
"secret": "<webhook-secret>",
"signature_header": "OTPBox-Signature",
"note": "the secret is shown once"
}
The event body:
{
"id": "evt_<message-id>",
"type": "message.received",
"created_at": "2026-10-20T18:21:05Z",
"inbox_id": "<inbox-id>",
"message": {
"id": "<message-id>",
"received_at": "2026-10-20T18:20:53Z",
"from": "Example <no-reply@example.com>",
"subject": "You have been invited",
"codes": [],
"verify_link": "https://staging.example.com/invite/accept?token=<token>"
}
}
The OTPBox-Signature header has the form t=<unix time>,v1=<hex>, where the hex value is HMAC-SHA256 over the timestamp, a dot and the raw body, keyed with the secret. Verify it before trusting the event:
// Verifies an OTPBox webhook. rawBody must be the exact bytes received.
import crypto from 'node:crypto';
export const verifyOtpboxSignature = ({ header, rawBody, secret, toleranceSeconds = 300 }) => {
const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')));
const age = Math.abs(Date.now() / 1000 - Number(parts.t));
if (!parts.t || !parts.v1 || age > toleranceSeconds) return false;
const expected = crypto.createHmac('sha256', secret).update(`${parts.t}.${rawBody}`).digest('hex');
const given = Buffer.from(parts.v1);
return given.length === expected.length && crypto.timingSafeEqual(Buffer.from(expected), given);
};
Delivery has a 10 second timeout and does not follow redirects. Failed deliveries are retried with a backoff that starts at 10 seconds and doubles up to one hour, for up to 24 hours. Retries reuse the event id, so deduplicate on id. Remove the webhook with DELETE /v1/inboxes/<inbox-id>/webhook.
QA for transactional e-mail templates
A real inbox is a convenient place to check your own password reset, invite and receipt mails after a template or provider change. GET /v1/messages/<message-id> returns what you need for assertions:
{
"subject": "Your receipt from Example",
"from": "Example Billing <billing@example.com>",
"from_address": "billing@example.com",
"sender_auth": "pass",
"auth": {
"spf": "pass",
"spf_domain": "mail.example.com",
"dkim": [{ "domain": "example.com", "result": "pass" }],
"dmarc": "pass",
"dmarc_policy": "reject",
"from_domain": "example.com"
},
"links": [
{ "url": "https://example.com/billing/receipts/<id>", "text": "View receipt", "kind": "other", "host": "example.com" },
{ "url": "https://example.com/unsubscribe?u=<id>", "text": "Unsubscribe", "kind": "unsubscribe", "host": "example.com" }
],
"has_remote_images": true,
"attachments": [
{ "index": 0, "filename": "receipt.pdf", "content_type": "application/pdf", "size": 48213, "sha256": "<sha256>", "inline": false }
]
}
(Shortened. The full object also has the text, headers, code candidates and the SMTP envelope.)
Checks that catch real regressions:
auth.dkimhas a passing signature for your domain, andauth.dmarcispass. A new sending provider or a DNS change that drops DKIM shows up here.- Every link
hostbelongs to the environment under test, and no link hasmismatch: true(visible text naming another site). - The
unsubscribelink exists on marketing-type mails and is absent where it should not be. - The subject matches the template for the locale you requested.
- Attachments have the expected type and a non-zero size.
Attachments: invoices and receipts
Download an attachment by its index. It is always served as a download (application/octet-stream), never rendered:
curl -s -o receipt.pdf \
https://otpbox.rc.center/v1/messages/<message-id>/attachments/0 \
-H "Authorization: Bearer $OTPBOX_KEY"
Compare its SHA-256 with the sha256 in the message to confirm the download is complete, then run whatever checks you have on the file.
Errors and limits
Errors are JSON, {"error": "<code>", "message": "<text>"}. The ones a CI job is likely to meet:
| Status | error | Meaning |
|---|---|---|
| 401 | unauthorized |
Missing, wrong or revoked key |
| 403 | plan_required |
The account’s plan does not include OTPBox |
| 404 | not_found |
Unknown inbox or message id |
| 409 | limit_reached |
Active inbox limit reached: delete inboxes you no longer need |
| 429 | limit_reached |
Too many waits running at once for the account |
| 429 | rate_limited |
Too many requests in a short time: retry after the Retry-After header |
Plan limits on rc.center Pro: 20 active inboxes, 1,000 messages per month, 30 messages per minute across the account, messages up to 10 MB, 1 GB of storage and 30-day retention. Retention is set by the plan; delete messages or inboxes sooner if you do not need them. Mail over a limit is refused at SMTP time with a temporary or permanent error, so the sending side sees it too.
OTPBox does not send mail, so it cannot test replies from the inbox side.
Endpoint reference
| Purpose | Method and path |
|---|---|
| Usage and quotas | GET /v1/usage |
| Create inbox | POST /v1/inboxes |
| List inboxes | GET /v1/inboxes |
| Get inbox | GET /v1/inboxes/{id} |
| Delete inbox | DELETE /v1/inboxes/{id} |
| Set webhook | PUT /v1/inboxes/{id}/webhook |
| Remove webhook | DELETE /v1/inboxes/{id}/webhook |
| List messages | GET /v1/inboxes/{id}/messages |
| Wait for a message | GET /v1/inboxes/{id}/wait |
| Get message | GET /v1/messages/{id} |
| Delete message | DELETE /v1/messages/{id} |
| Download attachment | GET /v1/messages/{id}/attachments/{index} |
The full OpenAPI 3.1 description is at https://otpbox.rc.center/v1/openapi.json. Every endpoint has an MCP tool twin, so the same inboxes can be used by an AI agent.


