send0
SDK

TypeScript SDK

Official TypeScript SDK for send0 with full type safety.

Installation

npm install send0

Requirements: Node.js >= 18.0.0

  • Zero runtime dependencies — uses native fetch
  • Dual ESM + CJS output
  • Full TypeScript types included

Quick start

import { Send0 } from 'send0';

const send0 = new Send0('sk_live_...');

// Send an email
const email = await send0.emails.send({
  from: 'hello@yourdomain.com',
  to: 'user@example.com',
  subject: 'Welcome!',
  html: '<p>Hello from send0</p>',
});

console.log(email.id); // em_xxxx
console.log(email.status); // 'queued'

Available resources

ResourceDescription
send0.emailsSend, get, list, cancel emails
send0.contactsCreate, update, list, delete contacts
send0.templatesManage email templates
send0.domainsDomain verification and management

Static utilities

// Verify webhook signatures
Send0.webhooks.verify();

Error handling

import { Send0, Send0APIError, Send0RateLimitError } from 'send0';

try {
  await send0.emails.send({ ... });
} catch (err) {
  if (err instanceof Send0RateLimitError) {
    console.log(`Retry after ${err.retryAfter}s`);
  } else if (err instanceof Send0APIError) {
    console.log(err.code, err.message, err.statusCode);
  }
}

Dev mode auto-detection

When NODE_ENV=development, the SDK automatically routes requests to localhost:2525 (the local dev server). No real emails are sent in dev mode.

Override with an explicit baseUrl in config:

const send0 = new Send0('sk_live_...', {
  baseUrl: 'https://api.send0.dev/v1',
});

Template support with JSX

Build email templates as React-like components with full type safety.

// emails/welcome.tsx
/** @jsxImportSource send0 */
import { Template, Text, Button } from 'send0/components';

export default function Welcome({ name }: { name: string }) {
  return (
    <Template preview={`Welcome, ${name}!`}>
      <Text>Hello {name},</Text>
      <Text>Welcome to our platform.</Text>
      <Button href="https://app.example.com">Get Started</Button>
    </Template>
  );
}