How to Use Notify with TypeScript/JavaScript

Send email with Notify using fetch — notifycx or fetch.

Send email from any JavaScript or TypeScript environment using the Fetch API. No dependencies needed.

Prerequisites

  • API key — generated when you sign up
  • Verified domain — required for production sends from a custom from address

Send an email

async function sendEmail() {
  const response = await fetch('https://notify.cx/api/email/send', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': process.env.NOTIFY_API_KEY!
    },
    body: JSON.stringify({
      from: 'noreply@your-verified-domain.com',
      to: 'recipient@example.com',
      subject: 'Hello world',
      html: '<h1>Welcome!</h1><p>Thanks for joining us.</p>'
    })
  });

  if (!response.ok) {
    throw new Error(`Failed to send email: ${await response.text()}`);
  }

  console.log('Email sent:', await response.json());
}

sendEmail();

Run this in Node.js 18+, Deno, Bun, or any environment with fetch. Keep your API key on the server — never expose it in browser code.

Prefer the html field (plain text or HTML). message and text are accepted aliases. See Sending Emails.


Where to next?