Notix
Integrations

Send email from a Cloudflare Worker.

A Worker sends through Notix with the fetch it already has; no dependency is needed for the send. Store the key with wrangler secret put, read it from env, and add the nodejs_compat flag only if you import notix-js, whose webhook verifier uses Node's crypto module.

The send

Send an email from Cloudflare Workers.

src/worker.ts
export default {
  async fetch(request: Request, env: { NOTIX_API_KEY: string }): Promise<Response> {
    const { to } = await request.json<{ to: string }>();
    const response = await fetch("https://app.usenotix.dev/api/v1/emails", {
      method: "POST",
      headers: { Authorization: `Bearer ${env.NOTIX_API_KEY}`, "Content-Type": "application/json" },
      body: JSON.stringify({ from: "Acme <receipts@acme.com>", to, subject: "Your receipt", html: "<p>Thanks.</p>" }),
    });
    return new Response(await response.text(), { status: response.status });
  },
};

The from address must be on a domain you have verified in Notix. Step by step: the cURL quickstart and the longer guide to sending email from Cloudflare Workers.

Secrets

The key as a Worker secret.

Run wrangler secret put NOTIX_API_KEY and read it from env inside the handler. A secret is encrypted and never shown in the dashboard or in wrangler.toml.

If the Worker imports notix-js, add compatibility_flags = ["nodejs_compat"] to wrangler.toml: the package imports node:crypto when it loads. A fetch-only Worker does not need it.

FAQ

Questions, answered.

Why does notix-js need nodejs_compat on Workers?
The package imports Node's crypto module for webhook signature checks when it loads. The nodejs_compat flag provides it; without the flag, send with fetch alone.
What if the same request runs twice?
Send an Idempotency-Key header (idempotencyKey in notix-js) with a value that names the thing being sent, such as order-4471-receipt. A repeat with the same key and body returns the first result and sends nothing new; the same key with a different body is refused with 409.
Why is my send refused with a from-address error?
The from address must be on a domain you have verified in Notix. Add the domain in the console, publish the DNS records it shows, and wait for verification; until then, sends from that domain are refused.

The free plan does not ask for a card.

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.