Skip to main content
Send email, SMS, and in-app notifications from an Express app with one Courier call in a route, and show the in-app message in a <courier-inbox>.
Save it as first-send.mts and run it with your key and email:
On a Test key, use your Courier login email, which Test email reaches with no provider. Look up the request id in Courier Logs.

courier-express-quickstart

The finished Express app from this guide, ready to clone and run.

Build this with a coding agent

Paste this prompt into Claude Code, Cursor, or Codex from your Express project root to have a coding agent add Courier:
Install the Courier skill with npx skills add trycourier/courier-skills, and connect the Courier MCP server so the agent can check Logs itself.

Rules for AI agents

  • Call @trycourier/courier through lib/courier.ts, not raw HTTP, and keep COURIER_API_KEY on the server.
  • Send all channels in one client.send.message with routing "all", dropping sms without a phone_number.
  • Send after the transaction commits, keyed task-assigned-${assignmentId}, and retry safely.
  • Mint the inbox JWT for res.locals.user, never a request’s user id, and answer 401 without one.
  • Build links from APP_URL, never the Host header, and never call providers directly.

What you’ll build

This Express 5 app uses Courier to notify a teammate who gets a task:
  • An email, a text, and an in-app message from one send in POST /tasks/:taskId/assign
  • A GET /courier/token route that signs the session user in to the inbox
  • A static <courier-inbox> page with no bundler
Tested in November 2026 with Express 5.3, @trycourier/courier 10.2.0, and Node.js 22.18.

Prerequisites

For the first send

For the full build

Clone the finished Express app

Clone the Courier Express quickstart and run it with your own key:
The steps below build these files:

Install the Courier Node.js SDK in your Express app

Install the Courier Node.js SDK, @trycourier/courier, with Express and tsx, which runs TypeScript:
Set "type": "module" in package.json and add scripts that load .env with tsx --env-file:
In a CommonJS app, keep its type and rename server.ts, lib/courier.ts, and top-level-await scripts to .mts, then import ./lib/courier.mts and point the scripts and any tsconfig.json include at server.mts. Then create .env:
.env

Send email, SMS, and in-app notifications from Express

In the Express app, notifyTaskAssigned makes one Courier call to POST /send that reaches email, SMS, and the inbox.
lib/courier.ts
{ maxRetries: 0 } fails a 429 or 409 fast instead of holding the request open, so retry from a queue.

Send from an Express route and mint the inbox token

The Express assign route calls Courier through notifyTaskAssigned after saving the assignment. The token route mints a one-user JWT with POST /auth/issue-token.
server.ts
Take the user from your session, never from the request. A token route that accepts a user id lets any caller read any user’s inbox. Put both routes behind the auth that sets res.locals.user. Refresh the token before its day is up.

Show in-app notifications on an Express page

Courier’s inbox is the <courier-inbox> web component, so a static page that Express serves from public/, such as the quickstart’s public/index.html, can import it from jsDelivr.
public/index.html

Verify

Assign a demo task in the Express app and watch Courier deliver it. Run npm run dev and open localhost:3000, where the inbox signs in as user_123. In the cloned repo, npm run send assigns a task and prints a request id. In your own app, call the assign route. Its response carries the requestId:
The message reaches the inbox and DEMO_EMAIL, plus SMS with DEMO_PHONE set. Search Logs for the request id to see each channel.

Go to production with Courier

Courier is notification infrastructure for humans and AI agents. Go live covers moving your Express app from Test to Production:
  • Retry from a queue. { maxRetries: 0 } fails connection errors, 429s, and 409s fast, so retry them with the same key, starting at 60 seconds.
  • Switch keys. Use a Production key with your providers connected.
  • Unset DEMO_EMAIL. While it’s set, every request acts as user_123.
  • Batch noisy events. A journey rolls them into a daily digest.

FAQ

Sending email from an Express app with Courier takes one client.send.message call with "email" in routing.channels. For welcome and reset emails, see the Next.js transactional email guide.
Courier’s SMTP integration sends through your SMTP server while your route calls client.send.message instead of transporter.sendMail. An SMTP server that allowlists IPs needs Courier’s AWS ranges.
Sending SMS from Node.js with Courier takes an E.164 phone_number on the recipient and "sms" in routing.channels. Connect Twilio or another SMS provider in Courier first.
An Express app adds Courier’s inbox with the <courier-inbox> web component and a token route for the session user. See Add an inbox.