api-testmail.codaipro.comREST + SSEBearer or keyless
Developer API

REST & Streaming API Reference

Programmatic endpoints to provision ephemeral inboxes, inspect inbound MIME messages, extract one-time passwords (OTP), and subscribe to live email event streams.

Testing with Automated Suites?

Get a free developer API key to unlock 60 req/min rate limits, telemetry logs, and dedicated namespace isolation.

Authentication Protocol

Authentication & Bearer Tokens

The Tempmail API supports two authentication workflows: Keyless Anonymous Access (ideal for instant browser test mailboxes) and Developer Bearer Token Access (intended for automated CI pipelines and elevated rate quotas).

HTTP Authorization Header:
Authorization: Bearer tm_live_a1b2c3d4e5f6...
Or via custom header:
X-API-Key: tm_live_a1b2c3d4e5f6...

API Endpoints Ledger

Live production endpoints hosted at https://api-testmail.codaipro.com

POST/api/emails/generate
RESOURCE ACTION201 Created

Generate Disposable Address

Instantly provisions an isolated disposable email address routed to your namespace. Defaults to a random 6-character tag if none is supplied.

Request Parameters (1)

HTTP POST
FieldLocationTypeRequiredDefaultDescription
tagquerystringNorandomCustom tag suffix (e.g. qa-trial). Valid characters: a-z, 0-9, hyphens.
curl -X POST "https://api-testmail.codaipro.com/api/emails/generate?tag=qa-trial" \
  -H "Authorization: Bearer tm_live_demo994821a8" \
  -H "Content-Type: application/json"
Response Payload (201 Created)application/json
{
  "email": "demo.qa-trial@inbox.testmail.app",
  "tag": "qa-trial",
  "namespace": "demo"
}
GET/api/emails/
FILTER / SEARCH200 OK

Query & Search Messages

Retrieves inbox messages matching tag, sender, subject, and attachment criteria. Includes livequery mode for synchronous long-polling in CI/CD pipelines. A private mailbox needs its recovery key in the X-Mailbox-Key header — a key in the query string would end up in every access log.

Request Parameters (10)

HTTP GET
FieldLocationTypeRequiredDefaultDescription
tagquerystringNononeExact tag match filter (e.g. qa-trial). Required for anonymous callers.
tag_prefixquerystringNononePrefix filter (e.g. qa- matches qa-1, qa-2). Admin only.
from_containsquerystringNononeSubstring filter on sender email address.
subject_containsquerystringNononeSubstring filter on subject line.
has_attachmentsquerybooleanNofalseFilter for messages containing attachments.
limitqueryintegerNo20Max emails to return (min: 1, max: 100).
offsetqueryintegerNo0Pagination offset.
retention_minutesqueryintegerNo10Retention cutoff window in minutes. Admin only — everybody else gets the configured window.
livequeryquerybooleanNofalseWaits up to 20s for next email if none currently exist. Returns an empty result on timeout, so poll again.
X-Mailbox-KeyheaderstringNononeRecovery key for a private mailbox. Sent as a header, never as a query parameter.
curl "https://api-testmail.codaipro.com/api/emails/?tag=qa-trial&limit=10&livequery=true" \
  -H "Authorization: Bearer tm_live_demo994821a8"
Response Payload (200 OK)application/json
{
  "result": "success",
  "count": 1,
  "limit": 10,
  "offset": 0,
  "has_more": false,
  "emails": [
    {
      "id": "msg-8f92a10c",
      "from": "auth@example.com",
      "to": "demo.qa-trial@inbox.testmail.app",
      "subject": "Security Code: 839210",
      "tag": "qa-trial",
      "timestamp": 1788936000000,
      "has_attachments": false,
      "has_html": true,
      "text_preview": "Your one-time authentication code is 839210..."
    }
  ]
}
GET/api/emails/{id}
RESOURCE200 OK

Fetch Email Details by ID

Retrieves the complete payload of an email, including rendered HTML body, plain text content, raw headers, spam score, and metadata. An email ID is not a credential: when the message belongs to a private mailbox, its recovery key is required.

Request Parameters (3)

HTTP GET
FieldLocationTypeRequiredDefaultDescription
idpathstringYesnoneThe unique message ID returned by the list endpoint.
retention_minutesqueryintegerNo10Retention override in minutes (admin only; 0 is the unlimited archive).
X-Mailbox-KeyheaderstringNononeRecovery key, required when the message belongs to a private mailbox.
curl "https://api-testmail.codaipro.com/api/emails/msg-8f92a10c" \
  -H "Authorization: Bearer tm_live_demo994821a8"
Response Payload (200 OK)application/json
{
  "id": "msg-8f92a10c",
  "from_addr": "auth@example.com",
  "to_addr": "demo.qa-trial@inbox.testmail.app",
  "subject": "Security Code: 839210",
  "timestamp": 1788936000000,
  "html": "<p>Your security code is <b>839210</b></p>",
  "text": "Your security code is 839210",
  "spam_score": 0.1,
  "attachments": [],
  "links": []
}
GET/api/emails/stream
EVENT STREAM200 Stream

Server-Sent Events (SSE) Live Stream

Subscribes to real-time email delivery events over a persistent HTTP connection with automatic keep-alive heartbeats every 15 seconds.

Request Parameters (1)

HTTP GET
FieldLocationTypeRequiredDefaultDescription
clientquerystringNononeOptional telemetry identifier for logging.
curl -N "https://api-testmail.codaipro.com/api/emails/stream" \
  -H "Authorization: Bearer tm_live_demo994821a8"
Response Payload (200 Stream)application/json
event: connected
data: {"message":"SSE connected","timestamp":1788936000000}

event: new_email
data: {"id":"msg-8f92a10c","subject":"Security Code: 839210","tag":"qa-trial","from":"auth@example.com"}
GET/api/emails/{id}/download
RESOURCE STREAM200 Stream

Download Raw RFC 822 (.eml)

Streams the complete untouched RFC 822 MIME message container suitable for archival or offline inspection.

Request Parameters (1)

HTTP GET
FieldLocationTypeRequiredDefaultDescription
idpathstringYesnoneThe unique message ID.
curl -OJ "https://api-testmail.codaipro.com/api/emails/msg-8f92a10c/download" \
  -H "Authorization: Bearer tm_live_demo994821a8"
Response Payload (200 Stream)application/json
[Binary RFC 822 Stream: msg-8f92a10c.eml]
GET/api/emails/attachments/{id}/{filename}
RESOURCE STREAM200 Stream

Stream Attachment File

Directly proxies binary attachments associated with a message with correct Content-Type and Content-Disposition headers.

Request Parameters (2)

HTTP GET
FieldLocationTypeRequiredDefaultDescription
idpathstringYesnoneThe unique message ID.
filenamepathstringYesnoneExact filename of the attachment.
curl -OJ "https://api-testmail.codaipro.com/api/emails/attachments/msg-8f92a10c/invoice.pdf" \
  -H "Authorization: Bearer tm_live_demo994821a8"
Response Payload (200 Stream)application/json
[Binary Content-Disposition: attachment; filename="invoice.pdf"]
GET/api/tags
COLLECTION RESOURCE200 OK

List Active Tags & Email Counts

Returns all recent active tags across the namespace along with message counts, ordered by inbound volume.

curl "https://api-testmail.codaipro.com/api/tags" \
  -H "Authorization: Bearer tm_live_demo994821a8"
Response Payload (200 OK)application/json
{
  "tags": [
    { "tag": "qa-trial", "count": 24 },
    { "tag": "auth-check", "count": 12 },
    { "tag": "ci-runner-8", "count": 5 }
  ]
}
GET/api/metrics
TELEMETRY RESOURCE200 OK

API Telemetry & Consumption

Reports live aggregate platform metrics including total request counts, average latency, active SSE streams, and uptime. The public response is an allowlist of aggregates; the request feed, consumer domains and per-endpoint counters need the admin key. Paths are stored as route templates, so a message ID never leaks through telemetry.

curl "https://api-testmail.codaipro.com/api/metrics"
Response Payload (200 OK)application/json
{
  "uptime_seconds": 86400,
  "total_requests": 28490,
  "avg_latency_ms": 1.4,
  "active_sse_connections": 14,
  "sources": {
    "official_web": 19200,
    "external_api": 9290
  }
}
GET/health
SYSTEM PROBE200 OK

Health Check & Upstream Probe

Returns the deployment state, credential configuration, and the cached upstream reachability flag. The upstream mail API is never called from this endpoint, so an anonymous health check cannot spend upstream quota. /health/live and /health/ready are available for hosting platforms.

curl "https://api-testmail.codaipro.com/health"
Response Payload (200 OK)application/json
{
  "status": "healthy",
  "service": "testmail-dashboard-api",
  "api_key_configured": true,
  "namespace": "demo",
  "demo_mode": false,
  "upstream_reachable": true
}
Telemetry & Quotas

Rate Limits & Throttling

Rate limiting is enforced at the edge to preserve throughput and prevent inbox flooding. Responses include standard rate-limiting headers.

Access TierRate LimitDaily QuotaLive Streaming (SSE)Telemetry Feed
Public Anonymous20 requests / min500 requests / dayEnabled (1 conn)Aggregates only
Developer API Key60 requests / min1,000 requests / dayEnabled (5 conns)Full audit log
Telemetry Headers:
X-RateLimit-Limit: 60 — Maximum allowed requests in the sliding window
X-RateLimit-Remaining: 58 — Available requests remaining
Retry-After: 60 — Seconds to wait when encountering 429 Too Many Requests

HTTP Status Codes & Errors

All error responses return structured JSON with a machine-readable type and human-readable message.

StatusIdentifierSemantic Description
200OKRequest succeeded and resource payload returned.
201CreatedResource generated successfully (e.g. new email address).
400Bad RequestMalformed parameters, invalid regex syntax, or invalid tag format.
401UnauthorizedInvalid, revoked, or missing API key when querying restricted endpoints.
404Not FoundEmail ID or requested attachment does not exist or expired.
422Validation ErrorQuery parameter out of bounds (e.g. limit > 100 or negative offset).
429Too Many RequestsRate limit exceeded. Check Retry-After header for cooldown duration.
500Internal ErrorUpstream gateway failure or temporary processing interruption.
Standard Error JSON Response (429):
{
  "result": "fail",
  "error": {
    "type": "rate_limited",
    "message": "Rate limit of 60 req/min exceeded. Try again in 60s."
  }
}

Server-Sent Events (SSE) Streaming Guide

Instead of hammering the server with polling requests, connect to the /api/emails/stream endpoint. Your test runner or application will receive real-time push events the millisecond a message is processed by the mail transfer agent.

// Native Browser or Node.js EventSource
const eventSource = new EventSource("https://api-testmail.codaipro.com/api/emails/stream");

// 1. Handshake confirmation
eventSource.addEventListener("connected", (e) => {
  console.log("Connected to stream:", JSON.parse(e.data));
});

// 2. Inbound email dispatch
eventSource.addEventListener("new_email", (e) => {
  const email = JSON.parse(e.data);
  console.log("Subject:", email.subject);
  console.log("From:", email.from);
  console.log("Tag:", email.tag);
});

// 3. Heartbeat keepalive
eventSource.addEventListener("heartbeat", (e) => {
  // Keep-alive received every 15 seconds
});