- The Node.js quickstart done, or at least a Courier API key in
COURIER_API_KEYand a user in Courier. - An Express app on Node 20 or newer, with
expressand@trycourier/courierinstalled.
1. Create the client once
Create oneCourier 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.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
- Working example: a runnable Node.js server with these calls.
- Node.js quickstart: users, channel routing, journeys, delivery status.
- Add an in-app inbox: your Express app mints the token, the browser renders the feed.
- Node.js SDK reference.