> ## 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.

> ## Agent Instructions
> Install the Courier skill before writing code: `npx skills add trycourier/courier-skills`. It carries the verified SDK shapes and the rules you cannot get wrong.
> Authenticate every request with `Authorization: Bearer <API_KEY>`. A workspace has several environments and each has its own keys, which are plain `pk_` strings with no environment prefix. Start with Test.
> Send with `client.send.message` from the Node SDK (`@trycourier/courier` v7 and later, where the client is the default import). Reference a template by its `nt_` id or its alias.
> A send accepts a bare Elemental element list, but storing content on a template requires the top-level elements wrapped in a channel element.
> To translate a template, write one locale at a time with `PUT /notifications/{id}/locales/{localeId}`, which merges into the existing translations. `PUT /notifications/{id}/content` and `PUT /notifications/{id}/elements/{elementId}` overwrite translations along with the content, so send each element's `id` and `locales` back, and first remove every `checksum` and any `locales` key that starts with an underscore.
> Templates and journeys can be built in the Courier app or created through the API. Either way they live in the workspace and are referenced by ID when you send.
> The hosted MCP server is https://mcp.courier.com. For a briefing on what Courier is and when to use it, read https://www.courier.com/llms.txt.
> Prefer the Guides tab for how-do-I questions and the Docs tab for how-does-it-behave questions. The API reference lives under /api-reference.

# Send a message

> Send a message with one API call, and Courier renders it, applies preferences, routes, and delivers. Choose between a template, a broadcast, or a journey.

A send is one API call. Name who it goes to and what it says. Courier renders it, applies preferences, routes, and delivers.

```javascript Node.js theme={null}
const { requestId } = await client.send.message({
  message: {
    to: { user_id: 'user_123' },
    template: 'nt_01kx4h2jdafq8bk9aftxak4b40',
    data: { name: 'Sarah Bennett' },
  },
});
```

```python Python theme={null}
response = client.send.message(
    message={
        "to": {"user_id": "user_123"},
        "template": "nt_01kx4h2jdafq8bk9aftxak4b40",
        "data": {"name": "Sarah Bennett"},
    },
)
```

```bash cURL theme={null}
curl -X POST https://api.courier.com/send \
  -H "Authorization: Bearer $COURIER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "message": {
      "to": { "user_id": "user_123" },
      "template": "nt_01kx4h2jdafq8bk9aftxak4b40",
      "data": { "name": "Sarah Bennett" }
    }
  }'
```

```ruby Ruby theme={null}
response = courier.send_.message(
  message: {
    to: { user_id: "user_123" },
    template: "nt_01kx4h2jdafq8bk9aftxak4b40",
    data: { name: "Sarah Bennett" }
  }
)
```

```go Go theme={null}
response, err := client.Send.Message(context.TODO(), courier.SendMessageParams{
	Message: courier.SendMessageParamsMessage{
		To: courier.SendMessageParamsMessageToUnion{
			OfUserRecipient: &shared.UserRecipientParam{
				UserID: courier.String("user_123"),
			},
		},
		Template: courier.String("nt_01kx4h2jdafq8bk9aftxak4b40"),
		Data: map[string]any{
			"name": "Sarah Bennett",
		},
	},
})
```

```java Java theme={null}
SendMessageParams params = SendMessageParams.builder()
    .message(SendMessageParams.Message.builder()
        .to(JsonValue.from(java.util.Map.of("user_id", "user_123")))
        .template("nt_01kx4h2jdafq8bk9aftxak4b40")
        .data(JsonValue.from(java.util.Map.of("name", "Sarah Bennett")))
        .build())
    .build();
client.send().message(params);
```

```php PHP theme={null}
$response = $client->send->message(
  message: [
    'to' => ['userID' => 'user_123'],
    'template' => 'nt_01kx4h2jdafq8bk9aftxak4b40',
    'data' => ['name' => 'Sarah Bennett'],
  ],
);
```

```csharp C# theme={null}
SendMessageParams parameters = new()
{
    Message = new()
    {
        To = new UserRecipient { UserID = "user_123" },
        Template = "nt_01kx4h2jdafq8bk9aftxak4b40",
        Data = new Dictionary<string, JsonElement>()
        {
            { "name", JsonSerializer.SerializeToElement("Sarah Bennett") },
        },
    },
};

await client.Send.Message(parameters);
```

```bash CLI theme={null}
courier send message \
  --api-key "$COURIER_API_KEY" \
  --message '{"to":{"user_id":"user_123"},"template":"nt_01kx4h2jdafq8bk9aftxak4b40","data":{"name":"Sarah Bennett"}}'
```

```text MCP theme={null}
With Courier MCP, send my nt_01kx4h2jdafq8bk9aftxak4b40 template to user_123 with their name.
```

The response returns a `requestId`, not a delivery result. Find it in [Logs](https://app.courier.com/logs) to confirm the message rendered and delivered.

## Prerequisites

* [A Courier API key](https://app.courier.com/settings/api-keys), and [the SDK for your language](https://www.courier.com/docs/sdk-libraries/sdks-overview.md) or curl
* [A template](https://www.courier.com/docs/design/templates/overview.md), for the `nt_` id in the call above
* [A saved user](https://www.courier.com/docs/recipients/overview.md), or their contact details inline in `to`
* [A connected provider](https://www.courier.com/docs/integrations/overview.md) for the channel it goes out on. Test email and the [inbox](https://www.courier.com/docs/in-app/overview.md) need none.

## Three ways to send

All three send the same content: a [template](https://www.courier.com/docs/design/templates/overview.md) you design once. What differs is what starts the send.

### 1. Templates

**Use a template when your application triggers the send.** A receipt, a password reset, an alert. Your app calls the API with a recipient and a template, like the example above. The template holds what the message says on every channel, plus its routing and brand settings. Your app supplies `data`, and the template's [variables](https://www.courier.com/docs/design/templates/variables.md) render each recipient's own version.

That split keeps a send small. Content changes ship by publishing the template, with no deploy.

> [card] [Design a Template](https://www.courier.com/docs/design/templates/overview.md)
>
> Build it in the visual editor, or manage it as JSON over the Templates API.

### 2. Broadcasts

**Use a broadcast when you choose the moment.** One message to a whole [list or audience](https://www.courier.com/docs/recipients/lists-and-audiences/overview.md), sent now or on a schedule. You pick the group, and Courier fans it out.

> [card] [Send a Broadcast](https://www.courier.com/docs/broadcasts/overview.md)
>
> Reach a saved list or audience in one send.

### 3. Journeys

**Use a journey when the send happens later, or depends on what the user does.** A multi-step flow that runs per user, with delays, branching, and enrichment between steps. A user event or an API call starts it, and the journey decides what comes next.

> [card] [Build a Journey](https://www.courier.com/docs/journeys/overview.md)
>
> Lay out steps, delays, and branches in the visual builder.

| | Templates | Broadcasts | Journeys |
| - | - | - | - |
| Shape | One message | One message to a group | Multi-step flow, per user |
| Started by | Your API call | You, now or scheduled | A user event or API call |
| Timing | Immediate, or a delay | Now or scheduled | Delays and waits between steps |
| Logic | In your code | None | Built-in branching |
| Best for | Transactional messages | Newsletters, announcements | Onboarding, digests, re-engagement |

## How it works

Every send is one `message` object posted to [`POST /send`](https://www.courier.com/docs/api-reference/send/send-a-message), whichever SDK you call it from. It has four parts:

```json theme={null}
{
  "message": {
    "to": { ... },
    "template": "...",
    "data": { ... },
    "routing": { ... }
  }
}
```

| Part | What it does | Example |
| - | - | - |
| `to` | Who gets it: a `user_id` for a stored [profile](https://www.courier.com/docs/recipients/overview.md), or contact details inline | `{ "user_id": "user_123" }` |
| `template` | What it says: a [template](https://www.courier.com/docs/design/templates/overview.md) by its `nt_` ID, or an [alias](https://www.courier.com/docs/design/templates/overview.md#send-it-by-id-or-alias) you assign | `"nt_01kx4h2jdafq8bk9aftxak4b40"` |
| `data` | The [variables](https://www.courier.com/docs/design/templates/variables.md) it fills in | `{ "name": "Sarah Bennett" }` |
| `routing` | Where it goes. Leave it out and the template's own [routing](https://www.courier.com/docs/send/routing.md) applies | `{ "method": "single" }` |

Pass an array in `to` to reach several recipients, or contact details inline for a one-off: `{ "email": "sarah@acme-corp.com" }`.

A message with no reusable design can carry its `content` inline instead of a `template`. That content is [Elemental](https://www.courier.com/docs/design/elemental/overview.md), the same format a template renders.

Courier enforces each recipient's [preferences](https://www.courier.com/docs/recipients/preferences/overview.md) at send time. Opt-outs and channel choices apply without extra logic in your code.

### The pipeline

```mermaid theme={null}
flowchart LR
    A["Your app"] --> B["Courier API"]
    B --> C["Provider"]
    C --> D["Your user"]
```

Courier records every step, so you can follow a message from request to delivery in [message logs](https://www.courier.com/docs/monitor/overview.md). Transient provider errors retry, and an unavailable provider or channel fails over to the next one.

### Idempotency

Send an `Idempotency-Key` header to make a retry safe. A repeated request with the same key returns the original response instead of sending again. A retry after a network failure can't duplicate the send.

> [!TIP]
>
> Add `routing` to pin the channels for this request, or `channels` and `providers` to adjust delivery settings. See [channel settings & overrides](https://www.courier.com/docs/send/overrides.md) and [how routing & failover work](https://www.courier.com/docs/send/routing.md).

## FAQ

> [accordion] Can I send to multiple users at once?
>
> Pass an array of recipients in `to`, or send to a [list or audience](https://www.courier.com/docs/recipients/lists-and-audiences/overview.md). For a large group, a list or audience send fans out for you (see [Send to lists & audiences](https://www.courier.com/docs/guides/announce-to-a-list.md)).

> [accordion] Does the API tell me if delivery succeeded?
>
> The API returns a `requestId`, not a delivery result, since the send runs asynchronously. Check delivery in [message logs](https://www.courier.com/docs/monitor/overview.md) or receive a `message:updated` [webhook](https://www.courier.com/docs/monitor/webhooks/outbound.md).

> [accordion] How do I prevent duplicate sends?
>
> Send an `Idempotency-Key` header. A second request with the same key returns the original result without sending again.
