How templates and routing strategies work together
Two pieces combine to send a notification:- A template holds the content: the subject, text, buttons, and variables, written in Courier’s Elemental format. It’s what the notification says.
- A routing strategy holds the delivery rules: which channels to use (email, SMS, inbox) and in what order. It’s how the notification gets there.
Prerequisites
- A Courier API key. The SDKs read it from
COURIER_API_KEY; curl passes it as a bearer token. - A provider for the channel you’ll send on. The test environment ships with a built-in email provider, so you can send right away. To use your own or send on other channels, add an integration.
Step 1: Create a routing strategy
Create the reusable delivery rules first. This basic strategy sends over email.method controls delivery: single tries channels in order until one succeeds (a fallback chain), and all sends to every channel at once. Add more channels to channels (for example ["email", "inbox"]) to fan out. Courier maps each channel to the provider you configured in your workspace.
rs_...). You’ll attach it to every template that should route this way.
Step 2: Create the template
Pass anotification object with a name, the routing strategy from Step 1, and content in the Elemental shape (a version plus elements like meta, text, and action). Courier creates it as a draft and returns the template, including the id you’ll publish and send.
id and state (DRAFT), plus the content and routing you attached.
Step 3: Publish it
A draft isn’t live yet. Publish it so it can send.Step 4: Send a notification
Send the template by id with the recipient and values for the variables in the content (order_id, name, tracking_url). The template’s routing decides the channels, so the send stays short. The example uses email, but you can use { "user_id": "..." } instead.
Use a Test API key while you iterate.
Step 5: Reuse the strategy on another template
This is the payoff. A second template, say an order-delivered email, reuses the same strategy id. No new routing to define: it inherits the same channels, and if you later change the strategy, both templates follow.Troubleshooting
Message status is UNROUTABLE
Message status is UNROUTABLE
Courier accepted the send but couldn’t pick a channel or provider. Either the template has no routing strategy attached (Steps 1 and 2), or the strategy’s channel has no provider configured in your workspace.
What’s next
Manage templates via the API
Update, replace, list, and archive templates
Routing strategies
Channel order, fallbacks, and provider config
How to build notifications with Elemental
Patterns for
content and channel overridesSend API
Request body, profiles, and routing