uSend Docs
Quickstarts

Send with Node.js

Send your first email from a Node.js script with the usend SDK.

You need a verified domain and an API key. The SDK needs Node.js 18 or newer and has no dependencies.

1. Install

Shell
npm install @usend/node

2. Set your API key

Shell
export USEND_API_KEY="us_123456789"

3. Send

Create send.mjs:

send.mjs
import { Usend } from '@usend/node';

const usend = new Usend(process.env.USEND_API_KEY);

const { data, error } = await usend.emails.send({
  from: 'Acme <[email protected]>',
  to: ['[email protected]'],
  subject: 'Hello from usend',
  html: '<p>It works!</p>',
});

if (error) {
  console.error(error.statusCode, error.name, error.message);
  process.exit(1);
}
console.log('queued', data.id);
Shell
node send.mjs

Every SDK method resolves to { data, error }; exactly one of them is null, so you never need try/catch around API errors.

Plain HTTP instead

JavaScript
const res = await fetch('https://api.usend.et/emails', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.USEND_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ from: 'Acme <[email protected]>', to: ['[email protected]'], subject: 'Hello', html: '<p>Hi</p>' }),
});
console.log(await res.json());

Next steps