How to Use Notify with TypeScript/JavaScript
Send email with Notify using fetch — no SDK required.
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 (optional) — required for production sends from a custom
fromaddress
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({
to: 'recipient@example.com',
subject: 'Hello world',
message: '<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.
The message field accepts plain text or HTML. See Sending Emails for examples of both formats.