DEVELOPER REFERENCE · REST API v1

PostZeno API Reference

Send verification codes, password resets, receipts, and opt-in updates over HTTPS. Every endpoint speaks UTF-8 JSON and authenticates with a single account API key.

Base URL (TLS 1.2+)
https://mail.postzeno.com/api/v1

01 / Getting Started

Quickstart

Verify your sending domain in the Console ↗ (or via the Domains API), create an API key, and send your first email in one HTTPS request.

curl -X POST https://mail.postzeno.com/api/v1/send \
  -H "X-API-Key: $POSTZENO_API_KEY" \
  -H "Idempotency-Key: signup-otp-98412" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "[email protected]",
    "from_name": "Acme Security",
    "to": ["[email protected]"],
    "subject": "Your verification code is 482910",
    "html_body": "<p>Your verification code is <strong>482910</strong>. It expires in 5 minutes.</p>",
    "metadata": { "user_id": "usr_42" }
  }'

02 / Security

Authentication

Include your API key in the X-API-Key request header on every call to https://mail.postzeno.com/api/v1:

HTTP Header
X-API-Key: ms_your_api_key_here
  • Server-side only: Store API keys in environment variables or a secret manager. Never expose keys in frontend JavaScript or mobile binaries.
  • Account isolation: Any active API key on your account can send from any verified domain in your account and query your account's submission receipts.
  • Key rotation: Create multiple keys per environment and revoke compromised keys immediately in the Console.

03 / Reliability

Idempotency

Both POST /api/v1/send and POST /api/v1/send/batch support the Idempotency-Key header (1–256 printable ASCII characters) to prevent duplicate sends when retrying after network timeouts.

  • 24-hour replay window: Repeating a succeeded (2xx) request with the same API key, endpoint, key, and JSON body replays the original response with header Idempotent-Replayed: true and deducts zero additional credits.
  • Safe error recovery: Non-2xx responses release the key immediately so you can retry with the same key.
  • Conflict protection: Reusing an existing key with a different payload—or sending a concurrent duplicate while the first call is still in flight—returns 409 CONFLICT.

04 / Error Handling

Errors & Status Codes

All non-2xx responses return a consistent JSON envelope with a machine-readable error.code and optional field-level details:

Error Envelope
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Request validation failed",
    "details": [
      { "field": "subject", "message": "subject is required" }
    ]
  }
}
CodeHTTPMeaning & Recommended Action
VALIDATION_ERROR400Invalid JSON, invalid/missing field, unavailable recipient domain, or insufficient email credits.
ATTACHMENT_TOO_LARGE400Single file exceeds 10 MB or total attachments exceed 25 MB.
UNAUTHORIZED401Missing, invalid, or revoked X-API-Key.
FORBIDDEN403Sender domain is not registered or does not belong to your account.
NOT_FOUND404Message ID, domain, or mailbox does not exist in your account.
CONFLICT409Resource already exists, or Idempotency-Key payload mismatch / in-flight request.
DOMAIN_UNVERIFIED409Sender domain has not passed SPF, DKIM, and DMARC verification yet.
RATE_LIMITED429Request rate limit exceeded; back off before retrying.
INTERNAL_ERROR500Unexpected server error; retry with exponential backoff and the same Idempotency-Key.
QUEUE_FULL503Temporary ingestion backpressure. No credits are charged; retry with backoff and the same Idempotency-Key.

05 / Billing Model

Credit Accounting

  • 1 credit per unique recipient: Each accepted email deducts 1 credit per unique recipient across to, cc, and bcc (case-insensitive deduplication within the same message).
  • No charge on rejected requests: Requests rejected with 4xx or 503 QUEUE_FULL consume zero credits. Failed items inside a batch request are not charged.
  • 5-year validity: One-time credit packs and subscription renewals share one balance; each new payment grants credits valid for 5 years.

06 / Email Sending & Receipts

Email Sending Endpoints

Send an Email

POST/api/v1/send

Accepts a single transactional or opt-in message for asynchronous delivery and returns a durable submission receipt.

Request Parameters

FieldTypeRequiredDescription
fromstringRequiredSender email address on a verified domain in your account.
from_namestringOptionalSender display name (no CR/LF characters).
tostring[]RequiredNon-empty array of primary recipient addresses.
cc / bccstring[]OptionalCarbon-copy and blind carbon-copy recipient lists.
subjectstringRequiredEmail subject line (UTF-8 supported, no CR/LF).
text_bodystringEitherPlain-text body. Provide text_body, html_body, or both.
html_bodystringEitherHTML body. Provide html_body, text_body, or both.
reply_tostringOptionalReply-To address (e.g. Support <[email protected]>).
headersobjectOptionalCustom headers (max 20; key <= 64 ASCII token chars; value <= 512 bytes, no CR/LF; system/DKIM/unsubscribe headers are reserved).
metadataobjectOptionalKey-value map (max 20 keys, <= 4 KB JSON). Omitted from MIME; returned in status lookups and unsubscribe webhooks.
attachmentsarrayOptionalObjects of {filename, content_type, content (base64), size}. Max 10 MB each, 25 MB total.
track_opensbooleanOptionalEmbeds a 1x1 open pixel in html_body (recipient-attributed on single-recipient emails). Default false.
track_clicksbooleanOptionalRewrites <a href> links in html_body for click tracking. Default false.

Response (200 OK)

JSON
{
  "message_id": "8f14e45f-ceea-467a-9a38-7f9028c14901",
  "status": "pending"
}

status is "pending" when accepted, or "unsubscribed" if a recipient previously opted out.

Send a Batch of Emails

POST/api/v1/send/batch

Submit up to 500 messages in one request. Each element in messages uses the exact same schema as POST /api/v1/send.

Response · 200 OK
{
  "total": 2,
  "success": 2,
  "results": [
    { "index": 0, "message_id": "3c8e7b12-9012-4d3a-81d2-5a771c992101", "status": "pending" },
    { "index": 1, "message_id": "9f2a14c0-4418-4f6b-b3a0-0d881122e304", "status": "pending" }
  ]
}

Retrieve Submission Status

GET/api/v1/send/{messageId}/status

Returns the submission receipt and open/click counts for a message belonging to your account (pending or unsubscribed, retained for 3 days), including any metadata passed at send time.

Response · 200 OK
{
  "message_id": "8f14e45f-ceea-467a-9a38-7f9028c14901",
  "status": "pending",
  "metadata": { "user_id": "usr_42" },
  "unique_opens": 1,
  "total_opens": 2,
  "unique_clicks": 1,
  "total_clicks": 1,
  "created_at": "2026-11-16T08:00:00Z",
  "updated_at": "2026-11-16T08:00:00Z"
}

List Submission Logs

GET/api/v1/send/logs?page=1&page_size=20

Paginated submission receipts for the authenticated API key, each including unique_opens, total_opens, unique_clicks, and total_clicks (retained for 3 days). Optional filters: status (pending | unsubscribed), start_time (RFC 3339), end_time (RFC 3339).

Response · 200 OK
{
  "items": [
    {
      "id": 42,
      "api_key_id": 7,
      "domain_id": 12,
      "message_id": "8f14e45f-ceea-467a-9a38-7f9028c14901",
      "from_addr": "[email protected]",
      "to_addr": "[\"[email protected]\"]",
      "subject": "Your verification code is 482910",
      "status": "pending",
      "metadata": { "user_id": "usr_42" },
      "unique_opens": 1,
      "total_opens": 2,
      "unique_clicks": 1,
      "total_clicks": 1,
      "created_at": "2026-11-16T08:00:00Z",
      "updated_at": "2026-11-16T08:00:00Z"
    }
  ],
  "total": 1,
  "page": 1,
  "page_size": 20
}

Retrieve Submission Statistics

GET/api/v1/send/stats?start_time=...&end_time=...

Requires start_time and end_time in RFC 3339 format. Returns submission and open/click tracking counts for the authenticated API key:

Response · 200 OK
{
  "total": 1250,
  "unsubscribed": 6,
  "unique_opens": 420,
  "total_opens": 680,
  "unique_clicks": 95,
  "total_clicks": 130
}
Open & click tracking retention (3 days): Pass "track_opens": true and/or "track_clicks": true with an html_body when sending. Automated scanner HEAD probes, known bot user-agents, and rapid duplicate hits (5-minute open window, 60-second click window) are filtered automatically. Submission receipts and tracking events are retained online for 3 days—poll /api/v1/send/logs or /api/v1/send/stats periodically to persist long-term analytics in your own database.

07 / Custom Domains

Sending Domains & DNS Verification

Automate domain onboarding for your own services or tenants using your X-API-Key.

MethodEndpointSummary
GET/api/v1/account/domainsList all domains in your account.
POST/api/v1/account/domainsAdd a domain ({"name": "yourdomain.com"}) and generate its 2048-bit DKIM keypair.
GET/api/v1/account/domains/{id}Get domain status and verification flags.
GET/api/v1/account/domains/{id}/dns-recordsFetch exact DNS records to configure at your registrar.
POST/api/v1/account/domains/{id}/verifyRun live DNS verification for SPF, DKIM, DMARC, and MX.
DELETE/api/v1/account/domains/{id}Remove domain, DKIM keypair, and associated mailboxes (204).

DNS Records & Live Verification

GET/api/v1/account/domains/{id}/dns-records

Each record returned includes type, host, value, required (boolean), and purpose ("send" or "receive").

Sending-only domains: Configure only the 3 records marked "required": true (SPF, DKIM, and DMARC). Do not add the optional "purpose": "receive" MX or A records unless you want PostZeno to receive incoming mail for your domain—modifying MX will route inbound mail away from Google Workspace, Microsoft 365, or your existing mail host.
End-to-End Domain Onboarding
# 1. Register your sending domain
curl -X POST https://mail.postzeno.com/api/v1/account/domains \
  -H "X-API-Key: $POSTZENO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "yourdomain.com"}'

# 2. Fetch the required SPF, DKIM, and DMARC records (use live response values)
curl https://mail.postzeno.com/api/v1/account/domains/12/dns-records \
  -H "X-API-Key: $POSTZENO_API_KEY"

# 3. Trigger live DNS verification once records propagate
curl -X POST https://mail.postzeno.com/api/v1/account/domains/12/verify \
  -H "X-API-Key: $POSTZENO_API_KEY"

Mailboxes (Optional)

Outbound sending works from any address on a verified domain without creating a mailbox first. To manage explicit mailboxes on your domain:

  • GET /api/v1/account/domains/{id}/mailboxes — List mailboxes on the domain.
  • POST /api/v1/account/domains/{id}/mailboxes — Create a mailbox with {"username": "noreply"}.
  • DELETE /api/v1/account/mailboxes/{id} — Delete a mailbox (204 No Content).

DNS Setup Guide

  • Single SPF record rule: Never create two v=spf1 TXT records on the same host. Merge include:postzeno.com into your existing SPF record before ~all or -all.
  • Host / Name formatting: Most DNS providers (Cloudflare, Route 53, GoDaddy, Namecheap) append your root domain automatically—enter @, _dmarc, and <selector>._domainkey without repeating .yourdomain.com.
  • 255-character TXT limit: If your registrar splits long TXT strings, wrap the 2048-bit DKIM value into two quoted segments separated by a space.
  • Automatic re-verification: Verified domains are checked every 6 hours. Transient DNS timeouts never interrupt sending.

08 / Event Notifications

Unsubscribe Webhooks

Single-recipient emails include standard List-Unsubscribe and RFC 8058 one-click headers. Configure an HTTPS webhook URL in Console → API Keys → Webhook or via the API to receive signed unsubscribed events.

Configure or Remove a Webhook

PUT/api/v1/account/webhook

Sets an HTTPS callback URL for the authenticated API key (or clears it when "webhook_url": ""). Returns a 64-character hex webhook_secret once. Use GET /api/v1/account/webhook to check the active URL.

cURL
curl -X PUT https://mail.postzeno.com/api/v1/account/webhook \
  -H "X-API-Key: $POSTZENO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"webhook_url": "https://hooks.yourdomain.com/postzeno"}'

Event Payload (POST to your webhook_url)

JSON Payload
{
  "event": "unsubscribed",
  "message_id": "8f14e45f-ceea-467a-9a38-7f9028c14901",
  "timestamp": "2026-11-16T08:12:05Z",
  "metadata": {
    "user_id": "usr_42"
  }
}

Verifying X-Webhook-Signature

Every webhook request includes X-Webhook-Signature: sha256=<hex> computed over the raw request body using HMAC-SHA256 and your webhook_secret. Return HTTP 2xx within 5 seconds (redirects are not followed; failed deliveries retry at 30s → 1m → 5m → 30m → 2h).

import crypto from "node:crypto";

export function verifyPostZenoWebhook(rawBodyBuffer, signatureHeader, secret) {
  if (!signatureHeader || !secret) return false;
  const expected = "sha256=" + crypto
    .createHmac("sha256", secret)
    .update(rawBodyBuffer)
    .digest("hex");
  const a = Buffer.from(signatureHeader, "utf8");
  const b = Buffer.from(expected, "utf8");
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}