Convex Transactional Email API (2026): Notify That a Job Finished from a Server Action with POST /emails
Send a “your job finished” notice from a Convex server-side action with Rovela’s HTTP API: a Bearer key from Convex environment variables, plain fetch to POST /emails, and an Idempotency-Key. Not an invented official Convex component or Rovela Convex SDK, and not an export-ready tutorial.
A job-finished notice is not an export-ready email, and it is not a client-side send
When a background job in your Convex app has already finished — a report your user queued, a rematch a worker just computed, a long import that finally settled — that user needs a clear message: “Your job finished,” plus a link to the result or status page. That send is transactional email. It is not a newsletter, not a broadcast, and it is not an “export is ready” tutorial. This guide uses the job-finished story on purpose, so the notice is about work that completed in your backend, not about a file download becoming available. It is also not a cron-mailer rewrite, and it is not a send from a Convex client function or the browser. This one is a server-side Convex action that posts HTTPS after the job record is already in a finished state.
Rovela’s Email API is a single HTTPS call for that work. There is no client library to install. The base URL is https://api.rovela.dev. You authenticate with Authorization: Bearer re_… (Authentication) and queue a message with POST /emails. The response is a message id. HTTP 200 means the message was accepted and queued, not that it has already arrived (Quick Start).
This guide stays inside documented Rovela fields on purpose. The examples use plain fetch from a Convex server-side action, plus a short curl, because the HTTP shape is the product — not an invented official Convex component, not a Rovela Convex SDK, and not a contacts, topics, or broadcasts product tour. Convex runs the action and stores the job; Rovela delivers the notice. The JSON body and headers are the same ones any runtime can send.
If you are still choosing between HTTP and SMTP, read Email API vs SMTP. Rovela’s SMTP is mailbox SMTP for mail apps (mx.rovela.dev:465, a device credential, send-as-self, 30 messages a minute from one client address). Programmatic volume from a Convex action belongs on POST /emails, which is also the distinction drawn in Email API vs SMTP relay.
What you need before the first Convex send
The first-email guide and the Quick Start are the same five steps, whether your caller is a Convex action or any other server:
- Create an account. You start on the free plan, which sends real mail. There is no separate sandbox or test key.
- Add and verify a sending domain (a subdomain such as
mail.example.comis a common choice). You cannot send from a domain you have not verified; an unverified or foreignfromis refused with a 400 that names the domain. The dashboard asks for four DNS records — SPF, DKIM, DMARC, and return-path. See the domain setup guide and what domain email is. - Create an API key. A
sending_accesskey can send and nothing else — the right default for a production Convex action. Afull_accesskey can also read messages and events, and manage domains, templates, and webhooks. The full key is shown once. - Send with
POST /emails. - Confirm delivery in the dashboard, with
GET /emails/:idorGET /emails/:id/events(those reads needfull_accessor a dashboard session), or with a webhook.
from is a string in the documented form "Jobs <jobs@yourdomain.com>". The address must sit on a verified sending domain. That is the same rule that makes domain email trustworthy: you prove you control the domain before you speak as it. How the display name and the address work is covered in the From name guide.
At least one of html, text, or template is required. Send both html and text where you can — many clients preview the text part, which is often where a user first sees the link to the finished job (HTML email API).
A Convex action that sends after the job is stored as finished
Keep the key out of the browser, out of a public repository, out of a Convex client function, and out of a container image. A leaked sending_access key can send mail as your domain. Store ROVELA_API_KEY as a Convex environment variable and read it only from a server-side action. Mutations and query functions are the wrong place for outbound HTTPS; an action is the documented Convex place for it. This guide does not invent an official Convex component or a Rovela package you would install into the dashboard.
Finish the job in your own tables first. You already know the job id, the job name, the user’s email, and the URL of the status or result page. The send is just the notice, with a link the user can open.
"use node";
import { action } from "./_generated/server";
import { v } from "convex/values";
const API = "https://api.rovela.dev/emails";
export const notifyJobFinished = action({
args: {
jobId: v.string(),
to: v.string(),
jobName: v.string(),
jobUrl: v.string(),
},
handler: async (_ctx, { jobId, to, jobName, jobUrl }) => {
const key = process.env.ROVELA_API_KEY;
if (!key) {
throw new Error("ROVELA_API_KEY is not set");
}
const res = await fetch(API, {
method: "POST",
headers: {
Authorization: `Bearer ${key}`,
"Content-Type": "application/json",
"Idempotency-Key": `job-finished-${jobId}`,
},
body: JSON.stringify({
from: "Jobs <jobs@mail.example.com>",
to,
subject: "Your job finished",
html: `<p>Your job finished.</p>
<p>${jobName}</p>
<p><a href="${jobUrl}">Open the result</a></p>`,
text: `Your job finished. ${jobName}. Open the result: ${jobUrl}`,
reply_to: "jobs@mail.example.com",
tags: { type: "job_finished", job_id: jobId },
}),
});
const body = await res.json();
if (!res.ok) {
throw new Error(`send failed ${res.status}: ${JSON.stringify(body)}`);
}
return body; // { object: "email", id: "..." }
},
});
// After your job record job_01J8K2 is stored as finished, schedule or call:
// await ctx.runAction(internal.emails.notifyJobFinished, {
// jobId: "job_01J8K2",
// to: "ada@example.com",
// jobName: "Weekly usage report",
// jobUrl: "https://app.example.com/jobs/job_01J8K2",
// });
The "use node" line is a Convex convention for actions that need Node’s fetch and process.env. It is not a Rovela SDK, and it is not an official mail component. Call the action only after the job row is already finished, typically from the worker path that wrote that status — not from the React client that queued the job.
tags are documented as arbitrary labels and are returned with the message, which makes later debugging in the dashboard or in a webhook payload much easier (email API tags). reply_to is optional; use it when the user should write back to a jobs mailbox rather than to the from address (email API reply-to). Put ROVELA_API_KEY in the Convex environment (email API authentication).
The same request is a short curl you can keep in a runbook or use when you are proving the payload before the action is deployed:
curl -X POST https://api.rovela.dev/emails \
-H "Authorization: Bearer re_your_sending_key" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: job-finished-job_01J8K2" \
-d '{
"from": "Jobs <jobs@mail.example.com>",
"to": "ada@example.com",
"subject": "Your job finished",
"html": "<p>Your job finished.</p><p>Weekly usage report</p><p><a href=\"https://app.example.com/jobs/job_01J8K2\">Open the result</a></p>",
"text": "Your job finished. Weekly usage report. Open the result: https://app.example.com/jobs/job_01J8K2",
"reply_to": "jobs@mail.example.com",
"tags": {"type": "job_finished", "job_id": "job_01J8K2"}
}'
Idempotency, recipients, and what a 200 actually means
Job runners retry. A Convex action can be retried after a transient error, or two finish paths can both observe the same completed job. Send an Idempotency-Key header (up to 256 characters). A retry of the same request within 24 hours returns the original response instead of sending again (idempotency). Keying the header to the job id (job-finished-<jobId>) keeps a second finish callback from becoming a second email.
A message may address at most 50 recipients across to, cc, and bcc combined. That is the transport’s limit, not a plan limit, and it is checked before the request is accepted. Quota is charged per recipient, not per message — cc and bcc count the same as to. A job-finished notice almost always has one to (the user who queued the work). If you also notify a teammate, remember that they count.
If you ever need to confirm many independent jobs in one go (a rare catch-up after a backlog drain, not the usual path), POST /emails/batch accepts up to 100 messages, each with the same schema. Two fields are rejected rather than ignored: template and topic_id. Send those through POST /emails. See the batch example and the batch transactional email guide. Each item should still carry its own business key if you send them as individual POST /emails calls; if you use the batch endpoint, keep the rest of the payload identical to a single send, without template or topic_id.
template is documented as { id, variables } and is mutually exclusive with html and text. This tutorial sends both html and text so the job name and the result link are visible in the notification preview. If you later switch to a stored template, use POST /emails (not batch) and follow the Templates API and the templates guide.
This guide does not attach the job’s output file. Attaching a file uses the documented attachments field { filename, content (base64), content_type }. Keep this notice to html and text, and let the result URL carry the download, unless you already have a file you need to include.
Errors you should handle in the Convex action
Documented send errors use an envelope of { statusCode, name, message }:
- 400 — a missing required field, a
fromdomain that does not belong to your organization, atemplatethat does not exist, or more than 50 recipients on one message. Fix the payload; retrying the same body will fail the same way. - 401 — a missing or invalid credential, or a
sending_accesskey used to read, reschedule, or cancel a message. Check the Convex environment variable the action is actually reading. - 429 — rate limit exceeded. Each message in a batch counts individually. Back off and retry with the same
Idempotency-Key(email API retries, rate limits).
Map 400 and 401 to a non-retryable failure, and 429 to a retry with the same key, so a typo in from does not spin the action. Broader patterns are in Email API error handling. Domain management endpoints such as GET /domains return 403 for a sending_access key — that is expected; leave domain work to the dashboard or a full_access key (Domains API, sending domains API).
Do not treat this send as an export-ready email. An export-ready notice is a different story: a file the user can download. This notice is that a job finished, with a status or result link. Keep the two moments separate if you later add an export flow.
Delivery is asynchronous — do not poll from the action
A 200 from POST /emails means accepted for delivery, not delivered. Reading GET /emails/:id or GET /emails/:id/events needs a full_access key or a dashboard session; a sending_access key cannot do it, and you should not add a polling loop inside the Convex action. Subscribe to a webhook instead, and verify the signature header x-resend-signature as documented in webhook security and signature verification. Event names include accepted, delivered, opened, clicked, bounced, or failed. For a single message you can also use the email delivery status API or the dashboard from a support session.
POST /emails/:id/cancel can cancel a message that has not been sent yet, which is relevant if you used scheduled_at and the job result was later discarded before the notice went out. Reading, rescheduling, and cancelling need full_access or a dashboard session. A request body for rescheduling is not documented here, so this guide does not invent one.
What not to do in a Convex project
- Do not put the Rovela key in a Convex client function, a React component, or a public repository. Client functions are visible to the browser.
- Do not install or advertise an official Rovela Convex component or SDK — there isn’t one in this guide, and inventing one would be a product claim we cannot make. A server-side action with plain
fetchis the whole integration. - Do not rewrite this as an export-ready tutorial, and do not send the notice from the client that queued the job. The lifecycle moment is “the job finished,” and the call to action is “open the result.”
- Do not send from mailbox SMTP for this. SMTP is for mail apps and mailboxes. A Convex action should use the HTTP API.
- Do not skip domain verification. An unverified
fromis refused. If you send on behalf of several tenants from one Convex deployment, a key restricted to a single domain limits the blast radius of a leak (Email API for multi-tenant SaaS).
A compact Convex checklist
- Verify the sending domain and create a
sending_accesskey (Quick Start). - Put
ROVELA_API_KEYin the Convex environment for a server-side action, not in a client function. - After your own job record is stored as finished, call the action that
POSTshttps://api.rovela.dev/emails. - Send both
htmlandtext, include the job name and the result URL, and setIdempotency-Keytojob-finished-<jobId>. - Optionally set
reply_toandtagssuch astype=job_finished. - Handle 400, 401, and 429 from the error envelope. Confirm delivery with a webhook, not by polling inside the action.
- If you are comparing providers, the existing pages are Rovela vs Mailgun, vs Amazon SES, vs Postmark, vs SendGrid, vs Resend, and vs Brevo. For the HTTP shape itself, see the transactional email API, the curl sending guide, and the HTTP email API overview. For other notification patterns, see the email notification API guide.
That is the whole integration: a job you already marked finished in Convex, one HTTPS POST from a server-side action, and a result link the user can open.