Node.js SDK
@irisend/sdk is published on npm with zero runtime dependencies, for Node 22+. Same { data, error } response shape and batch.send alias as Resend's own SDK.
InstallcURL
npm install @irisend/sdk
# or
pnpm add @irisend/sdkQuickstart
Every call returns Promise<{ data, error }> and never throws for an API or network failure.
send.tsTypeScript
import { Irisend } from "@irisend/sdk";
const irisend = new Irisend(process.env.IRISEND_API_KEY!);
const { data, error } = await irisend.emails.send({
from: "Acme <[email protected]>",
to: "[email protected]",
subject: "Welcome!",
html: "<p>Thanks for signing up.</p>",
});
if (error) {
console.error(error.name, error.statusCode, error.message);
} else {
console.log("sent", data.id);
}Send with a template
send-with-template.tsTypeScript
const { data: tpl } = await irisend.templates.create({
name: "Welcome",
from: "[email protected]",
subject: "Hi {{{FIRST}}}",
html: "<p>Hi {{{FIRST}}}, thanks for joining!</p>",
variables: [{ key: "FIRST", type: "string", fallbackValue: "there" }],
});
await irisend.templates.publish(tpl.id); // required before sending with it
await irisend.emails.send({
to: "[email protected]",
template: { id: tpl.id, variables: { FIRST: "Jane" } },
});Send with React Email
Pass a react element instead of html — it takes precedence when both are given. Rendering goes through the optional peer dependency @react-email/render, lazily imported so it's never required unless you actually pass react.
InstallcURL
npm install @irisend/sdk @react-email/render react react-domsend-react.tsxtsx
import { Irisend } from "@irisend/sdk";
import { WelcomeEmail } from "./emails/welcome"; // any React Email component
const irisend = new Irisend(process.env.IRISEND_API_KEY!);
await irisend.emails.send({
from: "Acme <[email protected]>",
to: "[email protected]",
subject: "Welcome!",
react: <WelcomeEmail name="Jane" />,
});
// react takes precedence over html when both are given. @react-email/render is an optional
// peer dependency, lazily imported — you only need it installed if you pass react.Receiving emails
emails.receiving lists and retrieves inbound mail; emails.receiving.attachments fetches each attachment's metadata and a 1-hour signed downloadUrl. See Receiving for the full API reference.
receiving.tsTypeScript
const { data: inbox } = await irisend.emails.receiving.list();
const { data: email } = await irisend.emails.receiving.get(inbox.data[0].id);
console.log(email.subject, email.html); // inline images are data: URIs by default
const { data: attachments } = await irisend.emails.receiving.attachments.list({
emailId: email.id,
});
for (const attachment of attachments.data) {
const res = await fetch(attachment.downloadUrl); // valid for 1 hour
const bytes = await res.arrayBuffer();
}Verifying webhooks
No built-in helperTypeScript
// @irisend/sdk ships no webhook-verification helper (the Python and PHP SDKs do). Use the
// framework-agnostic snippet in the Webhooks section below — it's the same Standard
// Webhooks / Svix-compatible scheme the server signs with.