The Courier Node.js SDK provides typed access to the Courier REST API from server-side TypeScript or JavaScript. Use it to send notifications, manage users and profiles, work with templates, and more. Available on GitHub and npm.Documentation Index
Fetch the complete documentation index at: https://www.courier.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Quick Start
Authentication
Get your API key from Settings > API Keys in the Courier dashboard. Set it as an environment variable:Sending Notifications
With a template
Design your notification in the template designer, then reference it by ID:With inline content
Skip templates and define content directly in code:To multiple recipients
Send to a list of users in a single call:Available Resources
The SDK covers the full Courier API. Every method is typed and documented in your editor on hover.| Resource | Namespace | Description |
|---|---|---|
| Send | client.send | Send messages to one or more recipients |
| Messages | client.messages | Retrieve status, history, and content of sent messages |
| Profiles | client.profiles | Create, update, and retrieve user profiles |
| Users | client.users | Manage preferences, tenants, and push tokens per user |
| Auth | client.auth | Issue JWT tokens for client-side SDK authentication |
| Bulk | client.bulk | Send messages to large recipient lists via jobs |
| Lists | client.lists | Manage subscription lists and their subscribers |
| Audiences | client.audiences | Define and query audience segments |
| Tenants | client.tenants | Manage tenants for multi-tenant setups |
| Automations | client.automations | Invoke multi-step automation workflows |
| Brands | client.brands | Manage brand settings (logos, colors, templates) |
| Notifications | client.notifications | List and inspect notification templates |
| Translations | client.translations | Manage localized content |
Common Operations
Checking Message Status
After sending, use therequestId to check delivery status or get the full event timeline:
Managing User Profiles
Profiles store recipient data (email, phone, custom fields) that Courier uses for delivery. You need a profile before you can send to auser_id.
create merges with any existing profile. Use replace for a full overwrite (any fields not included will be removed).Issuing JWT Tokens
If you use Courier’s client-side SDKs (React, JavaScript, mobile), your backend needs to issue JWT tokens for user authentication. Theauth.issueToken method handles this:
scope string controls what the token can access. Common scopes:
| Scope | Permission |
|---|---|
user_id:<id> | Which user the token is for (required) |
inbox:read:messages | Read inbox messages |
inbox:write:events | Mark messages as read/archived |
read:preferences | Read notification preferences |
write:preferences | Update notification preferences |
write:user-tokens | Register push notification tokens |
Bulk Sending
For large recipient lists, use the bulk API. It works in three steps: create a job, add users, then run it.TypeScript Types
The SDK ships with full TypeScript definitions for every request and response. Import them directly:Configuration
Error Handling
The SDK throws typed errors for API failures. All errors extendCourier.APIError:
| Status Code | Error Type |
|---|---|
| 400 | BadRequestError |
| 401 | AuthenticationError |
| 403 | PermissionDeniedError |
| 404 | NotFoundError |
| 422 | UnprocessableEntityError |
| 429 | RateLimitError |
| >=500 | InternalServerError |
| N/A | APIConnectionError |
Retries
The SDK automatically retries failed requests up to 2 times with exponential backoff. Retried errors include connection failures, 408, 409, 429, and 5xx responses.Timeouts
Requests time out after 60 seconds by default. Configure globally or per-request:APIConnectionTimeoutError is thrown. Timed-out requests are retried by default.
Logging
Enable debug logging with theCOURIER_LOG environment variable or the logLevel client option:
debug level, all HTTP requests and responses are logged including headers and bodies. You can also pass a custom logger (pino, winston, etc.):
Raw Response Access
Access HTTP headers or the underlyingResponse object:
More Operations
The SDK covers the full Courier REST API. Here are a few more resources beyond what’s documented above:| Resource | Method | Use case |
|---|---|---|
| User preferences | client.users.preferences.retrieve(userId) | Fetch a user’s notification preferences for your preference center |
| Cancel a message | client.messages.cancel(messageId) | Cancel a delayed or queued message before delivery (returns 409 if already delivered) |
| Push tokens | client.users.tokens.addSingle(token, { user_id }) | Register a device push token for iOS, Android, or React Native |
| Automations | client.automations.invoke.invokeAdHoc({ automation }) | Run a multi-step workflow (delay, send, update profile) via Automations |
API Reference
Full REST API docs with request/response examples.
Send API
Learn about the Send endpoint, routing, and message options.
Quickstart
Send your first notification in under two minutes.
GitHub
Source code, issues, and changelog.