Sign inGet Started

Node.js SDK

Send email with Express

Add a Parcel Wing-powered email endpoint to an Express API.

Install the SDK

The official SDK is published as @parcelwing/node.

Terminal

npm install @parcelwing/node

Send route

This route uses ParcelWingError to return structured SDK errors to your API client.

src/server.ts

import express from "express";
import { ParcelWing, ParcelWingError } from "@parcelwing/node";
 
const app = express();
const parcelWing = new ParcelWing({ apiKey: process.env.PARCEL_WING_API_KEY! });
 
app.use(express.json());
 
app.post("/send", async (req, res) => {
try {
const [message] = await parcelWing.emails.send({
from: "Acme <[email protected]>",
to: req.body.to,
subject: "Hello from Express",
text: "This email was sent from an Express route.",
});
 
res.json({ id: message?.id });
} catch (error) {
if (error instanceof ParcelWingError) {
res.status(error.status).json({ code: error.code, requestId: error.requestId });
return;
}
 
res.status(500).json({ error: "Unexpected error" });
}
});

Example app

The full Parcel Wing Node.js example app uses Express, the official SDK, and a local browser form for smoke testing.

Open example app