Package Exports
- send16-mail
Readme
Send16 Node.js SDK
The official Node.js SDK for the Send16 email platform. Built with TypeScript and works in Node.js, Deno, Bun, and edge runtimes.
Installation
npm install send16
# or
pnpm add send16
# or
yarn add send16Quick Start
import { Send16 } from 'send16';
const send16 = new Send16('sk_live_xxxxx');
const { data, error } = await send16.emails.send({
from: 'Acme <hello@acme.com>',
to: ['user@gmail.com'],
subject: 'Hello from Send16',
html: '<p>Hello world</p>',
});
if (error) {
console.error('Failed to send:', error.message);
} else {
console.log('Email sent:', data.id);
}Configuration
const send16 = new Send16('sk_live_xxxxx', {
baseUrl: 'https://api.send16.com', // default
timeout: 30000, // default: 30 seconds
});Emails
Send a single email
const { data, error } = await send16.emails.send({
from: 'Acme <hello@acme.com>',
to: ['user@gmail.com'],
subject: 'Hello',
html: '<p>Hello world</p>',
});Send with all options
const { data, error } = await send16.emails.send({
from: 'Acme <hello@acme.com>',
to: ['user@gmail.com'],
cc: ['cc@example.com'],
bcc: ['bcc@example.com'],
replyTo: 'support@acme.com',
subject: 'Invoice #1234',
html: '<p>Please find your invoice attached.</p>',
text: 'Please find your invoice attached.',
headers: {
'X-Custom-Header': 'value',
},
attachments: [
{
filename: 'invoice.pdf',
content: '<base64-encoded-content>',
contentType: 'application/pdf',
},
],
tags: [
{ name: 'category', value: 'invoices' },
],
scheduledAt: '2026-04-01T09:00:00Z',
});Batch send (up to 100 emails)
const { data, error } = await send16.emails.batch([
{
from: 'Acme <hello@acme.com>',
to: ['alice@example.com'],
subject: 'Hello Alice',
html: '<p>Hi Alice!</p>',
},
{
from: 'Acme <hello@acme.com>',
to: ['bob@example.com'],
subject: 'Hello Bob',
html: '<p>Hi Bob!</p>',
},
]);Contacts
Create a contact
const { data, error } = await send16.contacts.create({
email: 'user@test.com',
firstName: 'John',
lastName: 'Doe',
});List contacts
const { data, error } = await send16.contacts.list();
// With pagination
const { data, error } = await send16.contacts.list({ page: 2, limit: 50 });Get a contact
const { data, error } = await send16.contacts.get('contact-id');Update a contact
const { data, error } = await send16.contacts.update('contact-id', {
firstName: 'Jane',
unsubscribed: false,
});Delete a contact
const { data, error } = await send16.contacts.delete('contact-id');Domains
List domains
const { data, error } = await send16.domains.list();Get a domain
const { data, error } = await send16.domains.get('domain-id');Verify a domain
const { data, error } = await send16.domains.verify('domain-id');Error Handling
The SDK never throws on API errors. Every method returns { data, error }:
const { data, error } = await send16.emails.send({ ... });
if (error) {
console.error(error.code); // e.g. "HTTP_422", "TIMEOUT", "NETWORK_ERROR"
console.error(error.message); // Human-readable description
return;
}
// data is guaranteed to be non-null here
console.log(data.id);TypeScript
All types are exported for full type safety:
import type {
SendEmailPayload,
SendEmailResponse,
Contact,
Domain,
ApiResponse,
ApiError,
} from 'send16';License
MIT