Node SDK
Zero dependencies, TypeScript-first, Node 18+. It mirrors the REST API one-to-one, so anything in these docs maps directly to a method.
terminal
npm install noticeapi
Usage
app.ts
import { NoticeAPI } from "noticeapi";
const notice = new NoticeAPI(process.env.NOTICEAPI_KEY);
// Transactional
const { id } = await notice.emails.send(
{ from: "Acme <[email protected]>", to: "[email protected]",
subject: "Receipt", html: "<p>Thanks!</p>" },
{ idempotencyKey: `receipt-${orderId}` },
);
const email = await notice.emails.get(id);
// Batch (up to 100)
await notice.emails.batch([...]);
// Suppressions
await notice.suppressions.list();
await notice.suppressions.add("[email protected]", "user requested");
await notice.suppressions.remove("[email protected]");
// Marketing
const { audience } = await notice.audiences.create("Product updates");
await notice.contacts.create(audience.id, { email: "[email protected]" });
const { broadcast } = await notice.broadcasts.create({
audienceId: audience.id,
from: "Acme <[email protected]>",
subject: "June changelog",
html: "<h1>Hi {{{FIRST_NAME}}}</h1>...",
});
await notice.broadcasts.send(broadcast.id);Errors
Non-2xx responses throw NoticeAPIError with the HTTP status and the stable error code.
app.ts
import { NoticeAPIError } from "noticeapi";
try {
await notice.emails.send({ ... });
} catch (error) {
if (error instanceof NoticeAPIError) {
error.status; // 403
error.code; // "quota_exceeded" | "recipient_suppressed" | ...
}
}Point the client at staging or self-hosted instances with new NoticeAPI(key, { baseUrl }).