Send from an Express route. The Node.js guide covers the client setup; this page is the route itself. The SDK supports Node.js 22 or newer.
1. Install
npm install @sendpanda/sdkCreate a Send emails key and store it as SENDPANDA_API_KEY. The from address has to be on a domain verified in that project. See domain setup. A queued status means the API accepted the email, not that the recipient's server delivered it.
2. Send from a route
import express from "express";
import { SendPanda } from "@sendpanda/sdk";
const panda = new SendPanda(process.env.SENDPANDA_API_KEY!);
const app = express();
app.use(express.json());
app.post("/welcome", async (req, res) => {
const user = await userFromSession(req); // your own session
if (!user) return res.status(401).json({ error: "Sign in first" });
const email = await panda.emails.send(
{
from: "Your app <hello@your-verified-domain.com>",
to: [user.email],
subject: "Welcome",
text: "Welcome",
},
{ idempotencyKey: `welcome-${user.id}` },
);
res.status(202).json({ id: email.id, status: email.status });
});A route that sends to any address a request supplies is an open relay. Decide the recipient from your own session or database. Use one idempotency key per business event, and reuse that same key if the request is retried.