Skip to main content
The Node.js quickstart covers the calls themselves: create a user, send a notification, route it across channels, start a journey. This page is the Express wiring around them. Where the Courier client lives in an Express app, how a route sends, and how to keep a failed notification from failing the request it was attached to. Everything here is the same SDK, so the calls on the Node.js page drop straight into any handler. What you need
  • The Node.js quickstart done, or at least a Courier API key in COURIER_API_KEY and a user in Courier.
  • An Express app on Node 20 or newer, with express and @trycourier/courier installed.

1. Create the client once

Create one Courier instance at startup and import it wherever you send. It is a thin HTTP client with no connection state, so a module-level instance is the right shape and a per-request one is wasted work. new Courier() reads COURIER_API_KEY from the environment, which keeps the key out of your code and out of any bundle.

2. Send from a route

A route usually knows two things worth passing on: who the user is, and the data for this event. Name the template, name the user, and let Courier work out the channel from the template’s routing and the user’s preferences. The idempotency key means a client retry returns the original response instead of sending twice.

3. Do not fail the request on a failed send

A signup that worked should not return a 500 because a welcome notification did not go out. Wrap the send, log what failed, and answer the client either way. For anything slower or noisier than one send, hand the work to a job queue and have the route only enqueue it.
The requestId is worth logging. Paste it into Message Logs to see the channel Courier chose, the provider it used, and the delivery status.

Next steps