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" }
}'
const response = await fetch("https://mail.postzeno.com/api/v1/send", {
method: "POST",
headers: {
"X-API-Key": process.env.POSTZENO_API_KEY,
"Idempotency-Key": "signup-otp-98412",
"Content-Type": "application/json",
},
body: JSON.stringify({
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>.</p>",
metadata: { user_id: "usr_42" },
}),
});
const data = await response.json();
if (!response.ok) throw new Error(`${data.error?.code}: ${data.error?.message}`);
console.log(data.message_id, data.status);
import os
import requests
resp = requests.post(
"https://mail.postzeno.com/api/v1/send",
headers={
"X-API-Key": os.environ["POSTZENO_API_KEY"],
"Idempotency-Key": "signup-otp-98412",
"Content-Type": "application/json",
},
json={
"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>.</p>",
"metadata": {"user_id": "usr_42"},
},
timeout=10,
)
resp.raise_for_status()
print(resp.json()) # {'message_id': '...', 'status': 'pending'}
payload, _ := json.Marshal(map[string]any{
"from": "[email protected]",
"from_name": "Acme Security",
"to": []string{"[email protected]"},
"subject": "Your verification code is 482910",
"html_body": "<p>Your verification code is <strong>482910</strong>.</p>",
})
req, _ := http.NewRequestWithContext(ctx, http.MethodPost, "https://mail.postzeno.com/api/v1/send", bytes.NewReader(payload))
req.Header.Set("X-API-Key", os.Getenv("POSTZENO_API_KEY"))
req.Header.Set("Idempotency-Key", "signup-otp-98412")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
02 / Security
Authentication
Include your API key in the X-API-Key request header on every call to https://mail.postzeno.com/api/v1:
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
verifieddomain 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 headerIdempotent-Replayed: trueand deducts zero additional credits. - Safe error recovery: Non-
2xxresponses 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": {
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"details": [
{ "field": "subject", "message": "subject is required" }
]
}
}
| Code | HTTP | Meaning & Recommended Action |
|---|---|---|
VALIDATION_ERROR | 400 | Invalid JSON, invalid/missing field, unavailable recipient domain, or insufficient email credits. |
ATTACHMENT_TOO_LARGE | 400 | Single file exceeds 10 MB or total attachments exceed 25 MB. |
UNAUTHORIZED | 401 | Missing, invalid, or revoked X-API-Key. |
FORBIDDEN | 403 | Sender domain is not registered or does not belong to your account. |
NOT_FOUND | 404 | Message ID, domain, or mailbox does not exist in your account. |
CONFLICT | 409 | Resource already exists, or Idempotency-Key payload mismatch / in-flight request. |
DOMAIN_UNVERIFIED | 409 | Sender domain has not passed SPF, DKIM, and DMARC verification yet. |
RATE_LIMITED | 429 | Request rate limit exceeded; back off before retrying. |
INTERNAL_ERROR | 500 | Unexpected server error; retry with exponential backoff and the same Idempotency-Key. |
QUEUE_FULL | 503 | Temporary 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
1credit per unique recipient acrossto,cc, andbcc(case-insensitive deduplication within the same message). - No charge on rejected requests: Requests rejected with
4xxor503 QUEUE_FULLconsume 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
Accepts a single transactional or opt-in message for asynchronous delivery and returns a durable submission receipt.
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
from | string | Required | Sender email address on a verified domain in your account. |
from_name | string | Optional | Sender display name (no CR/LF characters). |
to | string[] | Required | Non-empty array of primary recipient addresses. |
cc / bcc | string[] | Optional | Carbon-copy and blind carbon-copy recipient lists. |
subject | string | Required | Email subject line (UTF-8 supported, no CR/LF). |
text_body | string | Either | Plain-text body. Provide text_body, html_body, or both. |
html_body | string | Either | HTML body. Provide html_body, text_body, or both. |
reply_to | string | Optional | Reply-To address (e.g. Support <[email protected]>). |
headers | object | Optional | Custom headers (max 20; key <= 64 ASCII token chars; value <= 512 bytes, no CR/LF; system/DKIM/unsubscribe headers are reserved). |
metadata | object | Optional | Key-value map (max 20 keys, <= 4 KB JSON). Omitted from MIME; returned in status lookups and unsubscribe webhooks. |
attachments | array | Optional | Objects of {filename, content_type, content (base64), size}. Max 10 MB each, 25 MB total. |
track_opens | boolean | Optional | Embeds a 1x1 open pixel in html_body (recipient-attributed on single-recipient emails). Default false. |
track_clicks | boolean | Optional | Rewrites <a href> links in html_body for click tracking. Default false. |
Response (200 OK)
{
"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
Submit up to 500 messages in one request. Each element in messages uses the exact same schema as POST /api/v1/send.
{
"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
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.
{
"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
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).
{
"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
Requires start_time and end_time in RFC 3339 format. Returns submission and open/click tracking counts for the authenticated API key:
{
"total": 1250,
"unsubscribed": 6,
"unique_opens": 420,
"total_opens": 680,
"unique_clicks": 95,
"total_clicks": 130
}
"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.
| Method | Endpoint | Summary |
|---|---|---|
GET | /api/v1/account/domains | List all domains in your account. |
POST | /api/v1/account/domains | Add 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-records | Fetch exact DNS records to configure at your registrar. |
POST | /api/v1/account/domains/{id}/verify | Run 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
Each record returned includes type, host, value, required (boolean), and purpose ("send" or "receive").
"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.
# 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=spf1TXT records on the same host. Mergeinclude:postzeno.cominto your existing SPF record before~allor-all. - Host / Name formatting: Most DNS providers (Cloudflare, Route 53, GoDaddy, Namecheap) append your root domain automatically—enter
@,_dmarc, and<selector>._domainkeywithout 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
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 -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)
{
"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);
}
import hashlib
import hmac
def verify_postzeno_webhook(raw_body: bytes, signature_header: str, secret: str) -> bool:
if not signature_header or not secret:
return False
expected = "sha256=" + hmac.new(
secret.encode("utf-8"), raw_body, hashlib.sha256
).hexdigest()
return hmac.compare_digest(signature_header, expected)
func VerifySignature(rawBody []byte, signatureHeader, secret string) bool {
if signatureHeader == "" || secret == "" {
return false
}
mac := hmac.New(sha256.New, []byte(secret))
mac.Write(rawBody)
expected := "sha256=" + hex.EncodeToString(mac.Sum(nil))
return hmac.Equal([]byte(signatureHeader), []byte(expected))
}