sendi-email
v0.1.7
Published
Node.js SDK for the Sendi email API
Downloads
691
Maintainers
Readme
Sendi Node.js SDK
The official Node.js SDK for the Sendi email API.
Install
npm install sendi-emailQuick Start
import { Sendi } from 'sendi-email';
const sendi = new Sendi('snd_your_api_key');
await sendi.emails.send({
from: '[email protected]',
to: '[email protected]',
subject: 'Hello from Sendi',
html: '<p>It just works.</p>'
});Emails
Send an email
const { id } = await sendi.emails.send({
from: '[email protected]',
to: '[email protected]',
subject: 'Welcome!',
html: '<h1>Welcome aboard</h1>',
// Optional
cc: '[email protected]',
bcc: ['[email protected]', '[email protected]'],
replyTo: '[email protected]',
attachments: [{ filename: 'invoice.pdf', content: '<base64>' }],
tags: { campaign: 'welcome' },
scheduledAt: '2026-03-08T12:00:00Z', // Schedule for later
});Batch send (up to 100)
const { data } = await sendi.emails.batch([
{ from: '[email protected]', to: '[email protected]', subject: 'Hi', text: 'Hello' },
{ from: '[email protected]', to: '[email protected]', subject: 'Hi', text: 'Hello' },
]);
// data = [{ emailId: '...' }, { emailId: '...' }]Get an email
const email = await sendi.emails.get('email_id');List emails
const { emails, pagination } = await sendi.emails.list({
page: 1,
limit: 50,
status: 'delivered',
});Update schedule
await sendi.emails.update('email_id', {
scheduledAt: '2026-03-09T15:00:00Z',
});Cancel scheduled email
await sendi.emails.cancel('email_id');Domains
// Add a domain
const domain = await sendi.domains.create({ domain: 'yourdomain.com' });
// List domains
const domains = await sendi.domains.list();
// Verify domain
const { verified } = await sendi.domains.verify('domain_id');
// Remove domain
await sendi.domains.remove('domain_id');Webhooks
// Create endpoint
const endpoint = await sendi.webhooks.create({
url: 'https://yourapp.com/webhooks',
events: ['email.delivered', 'email.bounced', 'email.opened'],
});
// endpoint.secret — save this for signature verification
// List endpoints
const endpoints = await sendi.webhooks.list();
// Toggle active/inactive
await sendi.webhooks.update('webhook_id', { active: false });
// Remove
await sendi.webhooks.remove('webhook_id');Analytics
// Email time series (7 or 30 days)
const { result, totalCounts } = await sendi.analytics.timeSeries({ days: 30 });
// Reputation metrics
const { bounceRate, complaintRate } = await sendi.analytics.reputation();
// Filter by domain
const stats = await sendi.analytics.timeSeries({ days: 7, domainId: 'domain_id' });Error Handling
import { Sendi, SendiError } from 'sendi-email';
try {
await sendi.emails.send({ ... });
} catch (err) {
if (err instanceof SendiError) {
console.log(err.message); // "Rate limit exceeded"
console.log(err.statusCode); // 429
}
}License
MIT
