Send Email Programmatically (2026): HTTP JSON from Any Language with Rovela
How to send email programmatically with Rovela: server-side Bearer keys, POST /emails, HTML plus text, Idempotency-Key, and why mailbox SMTP is the wrong volume path.
What “send email programmatically” means
Sending email programmatically means your code — a server, a worker, a cron, an automation — makes a request and a message is queued. It is not a person clicking Send in a mail app, and it is not a script that embeds a password in a frontend bundle. With Rovela, the program is any runtime that can POST JSON to https://api.rovela.dev/emails with Authorization: Bearer. There is no official SDK (Installation, Email API).
This is the language-agnostic contract. Send Transactional Email from Your App hooks the same call to product events. Email API Integration is the application architecture. Language walkthroughs include How to Send Email in Node.js, How to Send Email with Python, and Send Email with curl. For agents that only speak HTTP, see Send Email from an AI Coding Agent via HTTP.
Start from the Email API product page, the Quick Start, the Send Email API, and Authentication.
Related product guides in this series:
- Transactional Email Service
- REST Email API
- Email API for Startups
- Email API vs SMTP Relay
- Transactional Email Provider
- Email Delivery Status API
- Email API Authentication
- HTML Email API
- Email API Retries
- Email API for Multi-Tenant SaaS
- Receipt Email API
- Email API Logs
- Email API Rate Limits
- Transactional Email Infrastructure
The contract your program has to keep
- Call it from a server you control. Never put an API key in client-side code, a mobile app, or a public repository. A leaked
sending_accesskey is someone sending mail as your domain (Authentication). - Use a verified
from. The address must be on a domain you have verified. Anything else is refused with400naming the domain (Verified Domain Email API). - Send JSON, not a raw MIME blob. At minimum:
from,to,subject, andhtmland/ortext(or atemplate). Prefer both HTML and text (HTML Email API). - Treat
200as “queued.” Hold the returnedid. Delivery is asynchronous (Email Delivery Status API). - Make retries idempotent. If the process can time out and run again, send an
Idempotency-Key(up to 256 characters). A retry within 24 hours returns the original response (Idempotency Keys for Email APIs, Email API Retries).
Prefer a sending_access key in production. Reading status, cancelling, or managing domains needs full_access or a dashboard session — keep that key off the request path that only sends.
The same request in curl, Node, and Python
curl -X POST https://api.rovela.dev/emails \
-H "Authorization: Bearer re_your_sending_key" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: verify-signup-8f3a2c" \
-d '{
"from": "Acme <no-reply@yourdomain.com>",
"to": "alice@example.com",
"subject": "Your Acme code: 482913",
"html": "<p>Your verification code is</p><p style=\"font-size:28px;letter-spacing:6px\"><b>482913</b></p><p>It expires in 10 minutes.</p>",
"text": "Your verification code is 482913. It expires in 10 minutes."
}'
In Node, the documented shape is fetch:
const res = await fetch("https://api.rovela.dev/emails", {
method: "POST",
headers: {
Authorization: "Bearer " + process.env.ROVELA_API_KEY,
"Content-Type": "application/json",
"Idempotency-Key": `signup-verify:${userId}:${codeId}`,
},
body: JSON.stringify({
from: process.env.MAIL_FROM, // e.g. "Acme <no-reply@yourdomain.com>"
to: user.email,
subject: `Your Acme code: ${code}`,
html: `<p>Your verification code is <b>${code}</b>. It expires in 10 minutes.</p>`,
text: `Your verification code is ${code}. It expires in 10 minutes.`,
tags: { kind: "signup-otp", userId },
}),
});
if (!res.ok) {
const err = await res.json();
throw new Error(`Rovela ${res.status}: ${err.message}`);
}
const { id } = await res.json(); // accepted and queued — not yet delivered
In Python, the standard library is enough:
import json, os, urllib.request
def send_transactional(*, to, subject, html, text, idempotency_key, tags=None):
body = {
"from": os.environ["MAIL_FROM"],
"to": to,
"subject": subject,
"html": html,
"text": text,
}
if tags:
body["tags"] = tags
req = urllib.request.Request(
"https://api.rovela.dev/emails",
data=json.dumps(body).encode(),
headers={
"Authorization": "Bearer " + os.environ["ROVELA_API_KEY"],
"Content-Type": "application/json",
"Idempotency-Key": idempotency_key,
},
method="POST",
)
with urllib.request.urlopen(req) as resp:
return json.loads(resp.read().decode())
The key and the from address come from the environment (ROVELA_API_KEY, MAIL_FROM), not from source control. The Idempotency-Key should be derived from the logical action — signup-verify:${userId}:${codeId} — not from a random value generated on every retry, or the header cannot help you.
What not to use for programmatic volume
Rovela mailbox SMTP (mx.rovela.dev, port 465, device credential, send-as-self, 30 messages a minute from one client address) exists so Outlook, Apple Mail, and similar apps work on your domain (SMTP). It is the wrong tool for a worker that sends receipts or codes at volume: you lose idempotency keys, delivery webhooks, and the message-status API that the HTTP interface provides (Email API vs SMTP Relay, Migrate SMTP to an Email API).
After the program gets a 200
- While debugging,
GET /emails/:idor/eventswith afull_accesskey (Email Delivery Status API). - In production, register a webhook and verify the HMAC signature (Transactional Email Webhooks, Verifying Webhook Signatures).
- If you need many personalized messages at once,
POST /emails/batch(up to 100; notemplateortopic_idon that endpoint) (Batch Transactional Email API). - Log the API
messageon errors as-is.429means a rate limit or a spent monthly allowance — back off and check Email API Rate Limits.
FAQ
Can a cron job send mail this way? Yes. The job is just another server-side client. Use an Idempotency-Key that includes the window you meant to send in, so a rerun of the same tick does not double-send (Scheduled Email Sending). You can also set scheduled_at on a single POST /emails when the send time is known up front.
Can I send from a third-party automation host? Yes, if the workflow runs on a server, the key is stored as a secret, and you are not pasting it into a browser-side script.
Do I need to wrap MIME or pick a library like Nodemailer? Not for Rovela’s HTTP API. You are posting a JSON body. If you already use an SMTP library, the migration path is Migrate SMTP to an Email API.
What about GraphQL or tRPC? Those are your application APIs. The mail send still happens as this HTTP POST on the server (existing posts cover GraphQL and tRPC integrations if you need them). The programmatic contract does not change.
Put the send behind one function
Wrap POST /emails once — key, from, idempotency, error shape — and call that function from sign-up, billing, and security events. The rest of the program should never see the raw Bearer token. For the event-level hookup, continue with Send Transactional Email from Your App.