JMSURF Mail API documentation: send transactional email over REST
Introduction
JMSURF Mail sends transactional email (receipts, password resets, OTPs, invoices, alerts) from your own domain through a simple HTTPS API. Every request and response is JSON.
- Create an account (free to start).
- Add and verify your domain in Domains.
- Create an API key in API keys.
- Send your first email (below).
Base URL: https://api.jmsurfmail.co.ke/api/v1
Authentication
Send your API key in the Authorization header on every request:
Authorization: Bearer jm_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Full-access keys can send, read emails and manage domains. Send-only keys can only send: use them for small services. Keys are shown once when created: keep them in your server's environment variables, never in a website, mobile app or public code. Revoke a leaked key at once in the dashboard.
Send an email
POSThttps://api.jmsurfmail.co.ke/api/v1/emails
| Field | Type | Description |
|---|---|---|
| from | string | Sender, e.g. "Shop <[email protected]>". The domain must be verified on your account. |
| to | string | string[] | One or more recipients. |
| subject | string | The subject line. |
| html | string | HTML body. Send html, text or both. |
| text | string | Plain-text body. |
| cc, bcc | string | string[] | Optional. Up to 50 recipients in total per email. |
| reply_to | string | Optional reply address. |
| tags | string[] | Optional labels (up to 8) to find emails later. |
| headers | object | Optional custom X- headers. |
| attachments | array | Optional [{ filename, content (base64), content_type }]. 10 MB per email in total. |
| sms | object | Optional { to, message }: an SMS sent through your JMSURF SMS account at the same time. |
| template | string | Optional: the alias (or id) of a saved template. Its subject, html and text are used unless you send your own. |
| variables | object | Optional values for the template placeholders, e.g. { "name": "Customer" } fills {{name}}. |
Add an Idempotency-Key header (any unique string, e.g. your order id) and a retried request will never send twice.
curl https://api.jmsurfmail.co.ke/api/v1/emails \
-H "Authorization: Bearer $JMSURF_MAIL_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1024-confirmation" \
-d '{
"from": "Your Shop <[email protected]>",
"to": ["[email protected]"],
"subject": "Your order #1024 is confirmed",
"html": "<h1>Asante!</h1><p>We are packing your order.</p>",
"tags": ["order"]
}'Response:
{ "id": "4f1c2a3e-0d5b-4c7e-9a7f-2b1c9d0e8f11", "status": "sent" }status is sent when accepted for delivery. Later events (delivered, bounced, opened…) update it; see Webhooks.
Send a batch
POSThttps://api.jmsurfmail.co.ke/api/v1/emails/batch
Up to 100 emails in one request. Each item has the same fields as a single email. Each result is either { id, status } or { error, code }, in the same order.
{ "emails": [ { "from": "...", "to": "[email protected]", "subject": "...", "html": "..." }, { ... } ] }Find emails
GEThttps://api.jmsurfmail.co.ke/api/v1/emails/{id}
One email with its full event timeline.
{
"id": "4f1c…", "from": "Your Shop <[email protected]>", "to": ["[email protected]"],
"subject": "Your order #1024 is confirmed", "status": "delivered", "opened_at": "2026-10-08T09:14:03Z",
"events": [ { "type": "sent", "created_at": "…" }, { "type": "delivered", "recipient": "[email protected]", "created_at": "…" } ]
}GEThttps://api.jmsurfmail.co.ke/api/v1/emails?limit=20&before=2026-10-08T00:00:00Z
Newest first. Use the last created_at as before for the next page. Full-access keys only.
Domains
POSThttps://api.jmsurfmail.co.ke/api/v1/domains
{ "name": "savannah.co.ke" }Returns the DNS records to add at your DNS host (one TXT for ownership, two CNAMEs for DKIM signatures, and DMARC if you have none). We check automatically every 10 minutes, or call verify:
POSThttps://api.jmsurfmail.co.ke/api/v1/domains/{id}/verify
GEThttps://api.jmsurfmail.co.ke/api/v1/domains
DELETEhttps://api.jmsurfmail.co.ke/api/v1/domains/{id}
A domain's status is pending until all records are found, then verified. You can send from any address at a verified domain or its subdomains.
Usage
GEThttps://api.jmsurfmail.co.ke/api/v1/usage
{ "plan": "starter", "plan_name": "Starter", "status": "active", "renews_at": "…",
"month": { "sent": 4210, "allowance": 15000 }, "today": { "sent": 312, "cap": null }, "domains_allowed": 3 }Webhooks
Add an endpoint in Webhooks and choose events. We POST JSON to it as things happen:
{ "type": "email.delivered", "created_at": "2026-10-08T09:13:57Z",
"data": { "id": "4f1c…", "recipient": "[email protected]" } }| Field | Type | Description |
|---|---|---|
| email.delivered | The receiving server accepted it. | |
| email.bounced | It could not be delivered; the address is suppressed. | |
| email.complained | The recipient marked it as spam; the address is suppressed. | |
| email.opened | Opened (when tracking is on). | |
| email.clicked | A link was clicked; data.link has the URL. | |
| email.failed | We could not send it at all; data.error says why. |
Verify the signature. Every request has X-JMSURF-Signature: t=<unix time>,v1=<hex>, where v1 = HMAC-SHA256(your webhook secret, t + "." + raw body):
import crypto from "node:crypto";
function verify(rawBody, header, secret) {
const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300;
return fresh && crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(expected));
}Reply with any 2xx status within 10 seconds. Failed deliveries are retried 3 times.
Errors
Errors return a non-2xx status and { "error": "…", "code": "…" }.
| Field | Type | Description |
|---|---|---|
| 400 invalid_json | The body is not JSON. | |
| 401 invalid_api_key | Missing, wrong or revoked key. | |
| 403 domain_not_verified | The from-address domain is not verified on your account. | |
| 403 insufficient_scope | A send-only key tried something else. | |
| 413 too_large | The email is over 10 MB. | |
| 422 validation_error | A field is missing or wrong; the message says which. | |
| 429 quota_exceeded | Daily or monthly allowance used. Upgrade or wait. | |
| 429 rate_limited | More than 20 requests a second per key. | |
| 502 send_failed | Every delivery route refused it; the message says why. |
Limits
- 20 requests a second per API key (60 per IP).
- 50 recipients per email, 100 emails per batch, 10 MB per email.
- Monthly (and on Free, daily) allowances per plan; see pricing.
- Delivery logs are kept 7 days (Free), 30 (Starter), 90 (Business) or 365 (Scale).
Email + SMS
If your company uses JMSURF SMS (connected in JMSURF DASH), add an sms object and we send the text through your JMSURF SMS account in the same call:
"sms": { "to": "07XXXXXXXX", "message": "Your order SV-1024 has shipped" }The response includes sms: { ok, id } or { ok: false, error }. SMS is billed by JMSURF SMS from your SMS credit.
Templates
Save an email once under Templates in the dashboard, with placeholders such as {{name}}. Then send it by its alias and give the values:
{
"from": "Your Shop <[email protected]>",
"to": "[email protected]",
"template": "order-confirmed",
"variables": { "name": "Customer", "order": "SV-1024" }
}In HTML, {{name}} is made safe (special characters escaped); {{{name}}} inserts the value as HTML. Dotted names reach into objects: {{customer.name}}. Missing values become empty.
Backup SMTP
In Settings you can add your own SMTP server (host, port, user, password). If our delivery network refuses an email for a reason on our side (limits, outage), it is sent through your SMTP server instead, automatically. The email's log shows which route was used.
Code examples
Node.js
const r = await fetch("https://api.jmsurfmail.co.ke/api/v1/emails", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.JMSURF_MAIL_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({ from: "App <[email protected]>", to: "[email protected]", subject: "Your code", text: "Your code is 482913" }),
});
if (!r.ok) throw new Error((await r.json()).error);PHP
$ch = curl_init("https://api.jmsurfmail.co.ke/api/v1/emails");
curl_setopt_array($ch, [CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("JMSURF_MAIL_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(["from" => "App <[email protected]>", "to" => "[email protected]", "subject" => "Your code", "text" => "Your code is 482913"])]);
$res = json_decode(curl_exec($ch), true);Python
import os, requests
r = requests.post("https://api.jmsurfmail.co.ke/api/v1/emails", headers={"Authorization": f"Bearer {os.environ['JMSURF_MAIL_KEY']}"},
json={"from": "App <[email protected]>", "to": "[email protected]", "subject": "Your code", "text": "Your code is 482913"})
r.raise_for_status()Laravel / any SMTP-only app
Use the API from a small mail driver, or keep your SMTP for now and add it as the backup route. An SMTP relay is on our roadmap.
Security & policy
- All traffic is HTTPS. Keys are stored hashed; we cannot show a key again.
- Each account's data is private to it.
- Only transactional email and mail people asked for. Bulk mail to bought or scraped lists closes the account.
- Report abuse to [email protected].