By the end of this walkthrough, you will know how to create a workspace template from code, publish it so recipients can see it, confirm the published body, and send a real message that uses your template and variable data. You will also see how routing ties a template to your delivery setup, which is required when creating templates through the API. The example is a small shipping update email. For the full workspace route reference, see Templates API. For Design Studio-oriented API notes (routing, HTML blocks), see Manage Templates via API. For Elemental patterns beyond this walkthrough, see How to Build Notifications with Elemental.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.
Authenticate with your workspace API key.
GET /notifications can return both Classic and Elemental rows; inspect each item if you need a single editor type.Prerequisites
- Courier API key
curlfor the examples (the bash flow usesjqto read ids from JSON responses)- A routing strategy id (
strategy_idinsideroutingon a template). You can get one by listing your existing strategies (Step 1b below), creating a new one, or copying it from a template in Studio viaGET /notifications/{id}.
nt_...). The steps below store that in TEMPLATE_ID after the create call.
Step 1: List templates
See what is already on the workspace. The response is paginated; usecursor from paging for the next page if you need it.
cURL
Step 1b: Get or create a routing strategy
Every template needs a routing strategy that defines which channels to deliver on and in what order. If you already have astrategy_id from Studio or an existing template, skip ahead to Step 2.
List existing strategies
cURL
id:
Create a new strategy
If no strategy exists or you want a fresh one, create it with a name and routing configuration. Themethod field controls delivery: single tries channels in order until one succeeds; all sends to every channel simultaneously.
Step 2: Create a draft with Elemental content
Create a new notification template withPOST /notifications. The body is published, plus a notification object: metadata (name, tags, brand, subscription), routing with a strategy_id from your workspace, and content in the Elemental shape (version and elements). Courier returns a template id (commonly nt_...); use that value as TEMPLATE_ID in the following steps.
To replace an existing template in full, use
PUT /notifications/{id} with the same notification object shape. See Replace Notification Template. To create without overwriting, keep using POST /notifications as below. If validation fails, compare your payload to Create Notification Template.Step 3: Publish
Publish the current draft (or a specific version) withPOST /notifications/{id}/publish.
cURL
Step 4: Read published content
Confirm what is live:cURL
Step 5: Send a message with your template
CallPOST /send with your template id and values for the variables used in the draft (order_id, name, tracking_url). Put the recipient in message.to; the example below uses email. You can send to a Courier profile with to: { "user_id": "..." } instead. See Send a message for all to shapes.
The template must have a delivery channel and provider configured in Studio (for example email) or the send can fail routing. Use a Test API key while iterating.
What you built
You listed workspace templates, created a draft with Elemental content and routing, published it, read the published blocks, and sent a message that references the returned template id.What’s Next
Templates API reference
Endpoints, scope, and links to API Reference
Routing Strategies
Create and manage routing strategies in Studio or via API
How to Build Notifications with Elemental
Patterns for
content and channel overridesSend API
Request body, profiles, and routing