Documentation

SDKs / npm

Node.js email API SDK

TypeScript-first SDK for Node 18+ (ESM + CJS). Node.js 18 or newer (uses the global fetch).

Install

npm install mailstack

npm package ↗ Source on GitHub ↗

Quickstart

Send your first email — create an API key in the dashboard, then:

import { MailStack } from "mailstack";

const ms = new MailStack("ms_live_xxxxxxxxxxxx");

const { id, status } = await ms.emails.send({
  from: "hello@yourdomain.com",
  to: "user@example.com",
  subject: "Welcome to MailStack",
  html: "<h1>Hi there 👋</h1>",
});

console.log(id, status);

The send API is authenticated with your ms_live_ key. For dashboard resources (domains, templates, webhooks) pass your organization id too — see the REST API reference.

Verifying webhooks

Verify incoming webhook deliveries against the raw request body. The signature is an HMAC-SHA256 over {timestamp}.{body} carried in the MailStack-Signature header:

import { verifyWebhookSignature } from "mailstack";

const ok = verifyWebhookSignature({
  secret: process.env.MAILSTACK_WEBHOOK_SECRET!,
  payload: rawBody, // RAW request body string
  signature: req.headers["mailstack-signature"],
});

What's included

  • Single, batch, and personalized bulk sends
  • Pre-send lint, scheduled + cancelable sends
  • Messages, domains, templates, API keys, webhooks
  • Webhook signature verification helper
  • Full TypeScript types; ESM + CommonJS builds

Next steps

Browse the full REST API reference, read the quickstart, or compare the other official SDKs.