Send email from Convex actions.
Convex mutations cannot call out to the network, but actions can. Put the send in an action, read the key from the deployment's environment, and schedule the action from the mutation that decides an email is due, so the database write and the send stay separate.
Send an email from Convex.
import { v } from "convex/values";
import { internalAction } from "./_generated/server";
export const sendReceipt = internalAction({
args: { to: v.string(), orderId: v.string() },
handler: async (_ctx, { to, orderId }) => {
const response = await fetch("https://app.usenotix.dev/api/v1/emails", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.NOTIX_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": `order-${orderId}-receipt`,
},
body: JSON.stringify({ from: "Acme <receipts@acme.com>", to, subject: "Your receipt", html: "<p>Thanks.</p>" }),
});
if (!response.ok) throw new Error(`Notix answered ${response.status}`);
},
});
The from address must be on a domain you have verified in Notix. Step by step: the cURL quickstart.
The key in the deployment's environment.
Set it with npx convex env set NOTIX_API_KEY notix_xxxxxxxxxxxx, or in the dashboard's environment variables. Actions read it from process.env; nothing in the client bundle can.
From a mutation, schedule the send with ctx.scheduler.runAfter(0, internal.email.sendReceipt, { to, orderId }), so it runs only if the mutation commits.
Questions, answered.
Why an action and not a mutation?
What if the same request runs twice?
Why is my send refused with a from-address error?
Keep reading.
cURL
Send an email with one HTTP request from your terminal.
IntegrationsIntegrations
Notix inside the frameworks, platforms and AI coding tools you already use, from Next.js and Laravel to Supabase, Vercel and Cursor.
ProductEmail API
One JSON API for transactional and marketing email: send, batch, schedule, webhooks, typed SDKs.
NotixPricing
A free plan with no card, and Pro at $15 a month for 50,000 emails. Only sent volume is metered.
Send your first email in five minutes.
Verify a domain, copy an API key, make one call. The free plan does not ask for a card.