Sending Transactional Email with Postscale
Send application email through the Postscale REST API with idempotency, templates, metadata, and delivery webhooks.
TL;DR
For transactional email, send with a verified domain, include a stable idempotency key for retried application actions, attach metadata for correlation, and subscribe to delivery webhooks so the application knows what happened after submission.
What you will learn
- Send a transactional email through the REST API
- Add metadata and idempotency for reliable application workflows
- Connect send events to delivery, bounce, defer, and complaint webhooks
Before you send
Complete these prerequisites:
- Verify the sending domain.
- Confirm DKIM and DMARC pass.
- Create an API key with sending scope.
- Choose a From address users recognize.
- Set up delivery webhooks for bounces and complaints.
The domain setup guide covers DNS.
Send a simple message
Use the REST API for application-triggered mail:
curl https://api.postscale.io/v1/emails \
-H "Authorization: Bearer $POSTSCALE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "Acme <hello@mail.example.com>",
"to": [{"email": "user@example.net"}],
"subject": "Your receipt",
"html": "<p>Thanks for your purchase.</p>",
"text": "Thanks for your purchase."
}'
Always provide a plain-text part for clients that block HTML.
Use idempotency for retried actions
Payment callbacks, signup flows, and queue workers can retry. Use a stable idempotency key so the same application action does not produce duplicate mail.
Good keys include:
receipt:{payment_id}password-reset:{request_id}invoice:{invoice_id}:sent
Avoid using a random key generated on each retry.
Attach metadata
Metadata lets you correlate later delivery events:
{
"metadata": {
"tenant_id": "org_123",
"template": "receipt",
"order_id": "ord_456"
}
}
Keep metadata small and avoid secrets. It may appear in logs or webhook payloads.
Subscribe to delivery webhooks
Submission means Postscale accepted the email. It does not mean the final mailbox accepted it. Delivery webhooks close that loop.
At minimum, handle:
- Delivered.
- Deferred.
- Bounced.
- Complained.
- Suppressed.
Use these events to update user-facing status, suppress bad recipients, and alert on unusual failure rates.
Frequently asked questions
- Should I send transactional mail through REST or SMTP?
- Use REST for new application code because it is easier to validate, retry, and correlate. Use SMTP when integrating existing software that only speaks SMTP.
- Can I use templates and raw HTML?
- Yes. Templates are better for repeated product mail; raw HTML is useful for one-off generated messages.
Related guides
Put the guide into production
Postscale brings sending, inbound processing, DMARC reporting, and masked addresses behind one API so the operational pieces stay connected.