<courier-inbox>.
first-send.mts and run it with your key and email:
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: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/courierthroughlib/courier.ts, not raw HTTP, and keepCOURIER_API_KEYon the server. - Send all channels in one
client.send.messagewith routing"all", droppingsmswithout aphone_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 theHostheader, 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/tokenroute that signs the session user in to the inbox - A static
<courier-inbox>page with no bundler
@trycourier/courier 10.2.0, and Node.js 22.18.
Prerequisites
For the first send
- A Courier API key
- Node.js 22.18 or newer
For the full build
- An Express 5 app
- An SMS provider, such as Twilio
Clone the finished Express app
Clone the Courier Express quickstart and run it with your own key: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:
"type": "module" in package.json and add scripts that load .env with tsx --env-file:
package.json (additions)
package.json (additions)
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 throughnotifyTaskAssigned after saving the assignment. The token route mints a one-user JWT with POST /auth/issue-token.
server.ts
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
public/index.html
public/index.html
Verify
Assign a demo task in the Express app and watch Courier deliver it. Runnpm 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:
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 asuser_123. - Batch noisy events. A journey rolls them into a daily digest.
FAQ
How do I send email from an Express app?
How do I send email from an Express app?
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.Can I keep using Nodemailer or SMTP?
Can I keep using Nodemailer or SMTP?
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.How do I send SMS from Node.js?
How do I send SMS from Node.js?
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.How do I add an in-app notification inbox to Express?
How do I add an in-app notification inbox to Express?
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.