Send

JavaScript quickstart

Send your first email from any JavaScript runtime — Node, Bun, Deno, or an edge worker.

Install

bash
npm install @rkiza/sndr

The SDK is a tiny (~4 KB gzipped) wrapper around the public API. Works in Node 18+, Bun, Deno, Cloudflare Workers, and Vercel Edge — uses platform fetch, no native dependencies.

Send

js
import { Sndr } from '@rkiza/sndr';

const sndr = new Sndr(process.env.SNDR_API_KEY!);

const { id } = await sndr.emails.send({
  from: 'hello@yourdomain.com',
  to: 'customer@example.com',
  subject: 'Welcome aboard',
  html: '<p>Thanks for joining us.</p>',
});

The returned id can be used to look up the message via sndr.emails.get(id) or to subscribe to its lifecycle events through webhooks.

Without an SDK

SNDR is a plain HTTPS + JSON API. If you’d rather skip the dependency, fetch works just as well:

js
const res = await fetch('https://api.sndr.sh/v1/send', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.SNDR_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    from: 'hello@yourdomain.com',
    to: ['customer@example.com'],
    subject: 'Welcome aboard',
    html: '<p>Thanks for joining us.</p>',
  }),
});

if (!res.ok) {
  const { error } = await res.json();
  throw new Error(`${error.code}: ${error.message}`);
}

const { id } = await res.json();