DocsSending
Send with the API
Send sign-in codes, receipts and alerts from your own code.
The API is a single HTTPS endpoint that takes JSON. It's the best fit for email your own code sends to one person at a time: sign-in codes, password links, receipts and alerts. For the full list of endpoints, see the API reference.
Authentication
Create a key under Developers, API keys, and send it in the Authorization header of every request. Keys start with zm_ and are shown only once, so store yours in an environment variable on your server. Never put it in a web page or mobile app, where anyone could read it.
Authorization: Bearer zm_your_api_key
If your tool can't set that header, send the key as X-Api-Key: zm_your_api_key instead. A missing, wrong or revoked key gets a 401 response.
Send an email
POST https://app.zosmail.com/api/v1/emails
cURL
curl -X POST https://app.zosmail.com/api/v1/emails \
-H "Authorization: Bearer $ZOSMAIL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "Acme <[email protected]>",
"to": "[email protected]",
"subject": "Your sign-in code",
"html": "<p>Your code is <strong>123456</strong>. It expires in 10 minutes.</p>",
"text": "Your code is 123456. It expires in 10 minutes."
}'
PHP
$ch = curl_init('https://app.zosmail.com/api/v1/emails');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('ZOSMAIL_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'from' => 'Acme <[email protected]>',
'to' => '[email protected]',
'subject' => 'Your sign-in code',
'html' => '<p>Your code is <strong>123456</strong>.</p>',
]),
]);
$result = json_decode(curl_exec($ch), true);
Node.js
const response = await fetch('https://app.zosmail.com/api/v1/emails', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.ZOSMAIL_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
from: 'Acme <[email protected]>',
to: '[email protected]',
subject: 'Your sign-in code',
html: '<p>Your code is <strong>123456</strong>.</p>',
}),
});
const result = await response.json();
Python
import os
import requests
response = requests.post(
"https://app.zosmail.com/api/v1/emails",
headers={"Authorization": f"Bearer {os.environ['ZOSMAIL_API_KEY']}"},
json={
"from": "Acme <[email protected]>",
"to": "[email protected]",
"subject": "Your sign-in code",
"html": "<p>Your code is <strong>123456</strong>.</p>",
},
timeout=10,
)
result = response.json()
Fields
| Field | Description |
|---|---|
from | Required. An address on one of your verified domains, written as Acme <[email protected]>, as a bare address, or as {"email": "...", "name": "..."}. |
to | Required. One address, or a list of up to 50. Duplicates are removed, and each recipient gets their own copy with its own ID. |
subject | Required unless you send a template. Up to 998 characters. |
html | The HTML body. Send html, text or both. |
text | The plain-text body. Inbox providers trust email that includes one. |
reply_to | Optional. The address replies should go to. |
template_id | Optional. One of your saved templates, used for any subject, HTML or text you leave out. |
variables | Optional. Values for the placeholders in the subject and body. |
category | Optional. transactional, the default, or marketing for newsletters and promotions. |
The HTML and text together can be up to 50 KB. Attachments aren't supported yet; link to files instead.
Response
A 202 response means we accepted the email. You get one entry per recipient; keep each id if you want to check on it later.
{
"data": [
{
"id": "9b1f6c2e-4d0a-4c55-a1f2-6d2b8e7c1a90",
"from": "Acme <[email protected]>",
"to": "[email protected]",
"subject": "Your sign-in code",
"category": "transactional",
"status": "queued",
"created_at": "2026-11-26T10:15:02+00:00",
"sent_at": null,
"delivered_at": null
}
]
}
Templates and variables
Save a design once under Templates, then send only the values that change. Placeholders look like {{ name }}, and nested values can be reached with dots, such as {{ order.number }}. A placeholder without a value is left empty, and values are HTML-escaped in the HTML body.
POST https://app.zosmail.com/api/v1/emails
{
"from": "Acme <[email protected]>",
"to": "[email protected]",
"template_id": 12,
"variables": { "name": "Ada", "code": "123456" }
}
Check on an email
GET https://app.zosmail.com/api/v1/emails/{id}
Returns the same fields as the send response. sent_at, delivered_at, opened_at and clicked_at fill in as the email moves along. Opens are counted when the email's images load, so treat them as a guide rather than proof. What each status means.
Transactional or marketing
Leave category out for email written for one person. Set it to marketing for anything you send to many people. The difference matters: a spam report only stops email of the same kind, so someone who reports your newsletter still gets their sign-in codes. Marketing email waits for a short review by our team until your account is trusted; transactional email never waits.
Transactional email has strict rules, because it skips review.
- An email with exactly the same subject and content may reach at most 3 people within 24 hours.
- It may be reported as spam at most 3 times within 7 days.
Breaking either rule suspends the account. Read the rules.
When an email is refused
Every refusal comes with a message that says what went wrong, written so you can show it to your user when it's about their address. The most common ones:
422when a field is invalid or a recipient can't get email from your account, for example a typo such asgmial.com. Theerrorsobject says which field.402when you don't have enough credits for every recipient.403when your company details are incomplete, or sending is paused or the account suspended.
The API reference lists every status code.