> ## 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 daily digest

> Turn per-event notifications into one scheduled digest: link a journey's Send node template to a digest topic, and each user's schedule decides what waits.

Collapse a flood of individual notifications into one message a user will actually read.

Instead of ten emails about ten comments, a digest holds each event and delivers them together on the user's chosen schedule. Your journey keeps sending one notification per event, and each recipient's schedule decides whether it goes out now or waits for the digest.

## What you'll build

```mermaid theme={null}
flowchart LR
    A["Journey sends"] --> B{"Digest schedule?"}
    B -->|Yes| C["Held as DIGESTED"]
    C -->|On schedule| D["One digest sent"]
    B -->|No| E["Sent now"]
```

## Prerequisites

* [A journey with a Send node](https://www.courier.com/docs/journeys/build.md)
* [A subscription topic](https://www.courier.com/docs/recipients/preferences/preferences-editor.md)
* [A preference center](https://www.courier.com/docs/guides/build-a-preference-center.md)
* [A Courier API key](https://app.courier.com/settings/api-keys)

## How a digest works

A digest lives on a subscription topic, not on the journey. The topic holds the digest template, the schedules users choose from, and the categories. The journey's Send node only needs its template linked to that topic.

When the Send node runs, Courier checks the recipient's schedule for the topic. On a digest schedule the notification is held as `DIGESTED`, then released with everything else held for that recipient, rendered once with the digest template. On **Instant** it's delivered right away with the Send node's own template.

Two other journey nodes collect events, for different jobs:

| Node | Use it when |
| - | - |
| [Send to Digest](https://www.courier.com/docs/journeys/nodes/digest.md) | A step should add to the topic's digest without sending a notification of its own. An Instant recipient gets each event right away as a one-item digest. |
| [Batch](https://www.courier.com/docs/journeys/nodes/batch.md) | You want to group a burst by count or a quiet period inside the journey, not on a schedule the user picks. |

## Set up a topic digest

**1. Build the digest template**

Create a workspace template under **Content → Templates** that renders the collected events. The topic's template picker lists only workspace templates, so don't build it inside the journey. [Write the digest template](#write-the-digest-template) has a complete one. Don't link it to the topic, or it gets collected like any other send.

**2. Add the digest to the topic**

In the [preferences editor](https://app.courier.com/~/test/platform/preferences) (**Platform → Preferences**), open the subscription topic and click **Add Digest Schedules**, or **Edit Digest Schedules** once the topic has a digest. If the button is missing, turn on the **Digest Schedules** toggle. Pick your template under **Template**.

**3. Add schedules**

Add a **Daily** schedule and mark it default, plus an **Instant** option so users can opt out. Each schedule appears as a choice in the preference center.

**4. Save**

Click **Save** in the dialog, then **Save** at the top of the editor. Sends to the topic are held from that save on, before you publish.

Over the API, the same setup is the `digest` object on [`POST /preferences/sections/{section_id}/topics`](https://www.courier.com/docs/api-reference/preference-topics/create-topic-in-section). The REST fields are snake\_case:

```json theme={null}
{
  "name": "Task updates",
  "default_status": "OPTED_IN",
  "routing_options": ["email"],
  "digest": {
    "template_id": "nt_01kmrbwx4c8p2n6v0d3j7t9qf",
    "schedules": [
      { "frequency": "daily", "time": "09:00", "timezone": "America/New_York", "is_default": true },
      { "frequency": "instant" }
    ],
    "categories": [{ "category_key": "task_updates", "retain": "FIRST", "limit": 10 }]
  }
}
```

Categories are optional. They separate event types within one digest, such as tasks against comments. See [Schedules](#schedules) and [How digested items reach the template](#how-digested-items-reach-the-template) for every option.

## Write the digest template

At release, the digest template receives one object per category, with the total `count` and the collected `items`. Each item is the whole `data` of one send, so it repeats the category key:

```json theme={null}
{
  "task_updates": {
    "count": 3,
    "items": [
      { "task_updates": { "task_title": "Review landing page copy", "assignee_name": "Sarah Bennett" } }
    ]
  }
}
```

In Design Studio, build it from two blocks:

1. A **Text** block: `You have {{data.task_updates.count}} task updates.`
2. A **List** block with [**Loop on**](https://www.courier.com/docs/design/templates/design-studio.md#lists) turned on, **Data path** `data.task_updates.items`, and the item text `{{$.item.task_updates.task_title}} for {{$.item.task_updates.assignee_name}}`.

Over the API, the same template is this body for [`POST /notifications`](https://www.courier.com/docs/api-reference/templates/create-notification-template):

```json theme={null}
{
  "notification": {
    "name": "Daily task digest",
    "tags": [],
    "brand": null,
    "routing": null,
    "subscription": null,
    "content": {
      "version": "2022-01-01",
      "scope": "strict",
      "elements": [
        {
          "type": "channel",
          "channel": "email",
          "elements": [
            { "type": "meta", "title": "Your daily task updates" },
            { "type": "text", "content": "You have {{data.task_updates.count}} task updates." },
            {
              "type": "list",
              "list_type": "unordered",
              "loop": "data.task_updates.items",
              "elements": [
                {
                  "type": "list-item",
                  "elements": [{ "type": "string", "content": "{{$.item.task_updates.task_title}} for {{$.item.task_updates.assignee_name}}" }]
                }
              ]
            }
          ]
        }
      ]
    }
  },
  "state": "PUBLISHED"
}
```

> [!WARNING]
>
> **Match `data.` to the template's scope.** Templates saved in Design Studio or the Journeys editor use strict scope, so data paths start with `data.`. A template created over the API without `"scope": "strict"` reads `{{task_updates.count}}` instead, and every `data.` path outside a list loop renders as an empty string with no error. This applies to the digest template and to the Send node's template. Set `"scope": "strict"` on both and write `data.` everywhere.

Use a **List** block, not a Handlebars `{{#each}}` in a text block. Both render, but only the list block can be reopened in Design Studio. The loop path starts with `data.` in every scope, and each item is `$.item`.

## Link the journey template to the topic

In the Journeys editor, select the Send node and click **Edit** under **Message**. Open the template's settings (the gear icon) and choose the topic under **Subscription Topic**. Publish the template, then the journey. A run sends the template's published version.

Over the API, the link is `subscription` on the journey template's `notification`, set when you create it with [`POST /journeys/{templateId}/templates`](https://www.courier.com/docs/api-reference/journeys/create-a-notification-template-scoped-to-a-journey) or replace it with [`PUT /journeys/{templateId}/templates/{notificationId}`](https://www.courier.com/docs/api-reference/journeys/replace-a-journey-scoped-notification-template). The replace body takes only `notification`. A top-level `channel`, as in the create body, returns `400`:

```json theme={null}
{
  "notification": {
    "subscription": { "topic_id": "pt_01kx4h2jdafq8bk9a26x0kvd1t" }
  }
}
```

Build the journey in this order: create it with only a trigger and an exit, create its template, add the Send node with a replace, then publish the template and the journey. [Build with the API](https://www.courier.com/docs/journeys/build.md#build-with-the-api) walks through each call.

## Invoke the journey once per event

Each event is one item. Invoke the journey once per event with [`POST /journeys/{templateId}/invoke`](https://www.courier.com/docs/api-reference/journeys/invoke-a-journey), and nest the event's fields under the category name. The top-level `data` key is how a send joins a category:

```json theme={null}
{
  "user_id": "user_123",
  "data": {
    "task_updates": { "task_title": "Review landing page copy", "assignee_name": "Sarah Bennett" }
  }
}
```

Don't send `count` or `items` yourself. Courier builds them at release.

## Which schedule a user is on

A user picks their schedule in the preference center. To set it from your backend, pass `digest_schedule_id` on [`PUT /users/{user_id}/preferences/{topic_id}`](https://www.courier.com/docs/api-reference/user-preferences/update-or-create-user-preferences-for-a-subscription-topic). Schedule ids come back on the topic as `digest.schedules[].schedule_id`:

```json theme={null}
{
  "topic": { "status": "OPTED_IN", "digest_schedule_id": "sch_01m26nhsf7fzxr5kngwf8p0b2c" }
}
```

Send `null` to put the user back on the topic default. A user who has never picked a schedule falls back to the topic's default schedule, or to its first schedule when none is marked default.

That fallback is the usual reason a test never digests. If **Instant** is the default, every new user gets each notification immediately. Make a non-instant schedule the default, or put the test user on one first.

## Verify

**1. Confirm notifications are held**

Put a test user on the Daily schedule and invoke the journey for them three times. The message log shows each notification as `DIGESTED`.

**2. Release the digest now**

Instead of waiting for the schedule, release that user's held digest with [`POST /preferences/sections/{section_id}/topics/{topic_id}/digest/release`](https://www.courier.com/docs/api-reference/digests/release-a-recipients-digest). Pass `tenant_id` too if you sent in a tenant context. The topic's **Test** button in the preferences editor does the same for one recipient you pick.

**3. Read the digest**

The release returns `204` with no message ID. Find the digest with [`GET /messages`](https://www.courier.com/docs/api-reference/messages/list-messages) filtered by `recipient`, then read its subject and body with [`GET /messages/{message_id}/output`](https://www.courier.com/docs/api-reference/messages/get-message-content). It should show a count of 3 and all three items.

**4. Confirm Instant still delivers**

Switch the test user to Instant and invoke the journey again. The notification delivers on its own with the Send node's template.

The release call from step 2:

```javascript Node.js theme={null}
await client.workspacePreferences.topics.releaseDigest('pt_01kx4h2jdafq8bk9a26x0kvd1t', {
  section_id: 'ps_01kx4h0p3rf9w2k8a5c7d1e6tq',
  user_id: 'user_123',
});
```

```python Python theme={null}
client.workspace_preferences.topics.release_digest(
    topic_id="pt_01kx4h2jdafq8bk9a26x0kvd1t",
    section_id="ps_01kx4h0p3rf9w2k8a5c7d1e6tq",
    user_id="user_123",
)
```

```bash cURL theme={null}
curl -X POST https://api.courier.com/preferences/sections/ps_01kx4h0p3rf9w2k8a5c7d1e6tq/topics/pt_01kx4h2jdafq8bk9a26x0kvd1t/digest/release \
  -H "Authorization: Bearer $COURIER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "user_id": "user_123" }'
```

```ruby Ruby theme={null}
courier.workspace_preferences.topics.release_digest(
  "pt_01kx4h2jdafq8bk9a26x0kvd1t",
  section_id: "ps_01kx4h0p3rf9w2k8a5c7d1e6tq",
  user_id: "user_123"
)
```

```go Go theme={null}
err := client.WorkspacePreferences.Topics.ReleaseDigest(
	context.TODO(),
	"pt_01kx4h2jdafq8bk9a26x0kvd1t",
	courier.WorkspacePreferenceTopicReleaseDigestParams{
		SectionID: "ps_01kx4h0p3rf9w2k8a5c7d1e6tq",
		TopicDigestReleaseRequest: courier.TopicDigestReleaseRequestParam{
			UserID: "user_123",
		},
	},
)
```

```java Java theme={null}
TopicReleaseDigestParams params = TopicReleaseDigestParams.builder()
    .sectionId("ps_01kx4h0p3rf9w2k8a5c7d1e6tq")
    .topicId("pt_01kx4h2jdafq8bk9a26x0kvd1t")
    .topicDigestReleaseRequest(TopicDigestReleaseRequest.builder()
        .userId("user_123")
        .build())
    .build();
client.workspacePreferences().topics().releaseDigest(params);
```

```php PHP theme={null}
$client->workspacePreferences->topics->releaseDigest(
  'pt_01kx4h2jdafq8bk9a26x0kvd1t',
  sectionID: 'ps_01kx4h0p3rf9w2k8a5c7d1e6tq',
  userID: 'user_123',
);
```

```csharp C# theme={null}
TopicReleaseDigestParams parameters = new()
{
    SectionID = "ps_01kx4h0p3rf9w2k8a5c7d1e6tq",
    TopicID = "pt_01kx4h2jdafq8bk9a26x0kvd1t",
    UserID = "user_123",
};

await client.WorkspacePreferences.Topics.ReleaseDigest(parameters);
```

```bash CLI theme={null}
courier workspace-preferences:topics release-digest \
  --api-key "$COURIER_API_KEY" \
  --section-id ps_01kx4h0p3rf9w2k8a5c7d1e6tq \
  --topic-id pt_01kx4h2jdafq8bk9a26x0kvd1t \
  --user-id user_123
```

```text MCP theme={null}
With Courier MCP, release the held digest for user_123 on my task updates topic now.
```

## Schedules

Each entry in `digest.schedules` has a `frequency`: `instant`, `daily`, `weekdays`, `weekly`, `custom_days`, or `monthly`. Every frequency except `instant` needs a 24-hour `time`. `weekly` also needs `day_of_week`, `custom_days` needs `days_of_week`, and `monthly` needs `day_of_month`:

```json theme={null}
{
  "frequency": "custom_days",
  "days_of_week": ["tuesday", "thursday"],
  "time": "09:00",
  "timezone": "America/New_York",
  "is_default": true
}
```

* **Timezone:** an IANA zone, DST aware. Without one, the time is read as UTC. It's the schedule's zone, not each recipient's.
* **Default:** `is_default: true` marks the schedule new users start on.
* **Replacing:** the `schedules` array replaces what is stored. Pass a schedule's `schedule_id` to keep it. Any schedule you leave out is deleted. A kept schedule is stored exactly as sent, so restate its `timezone` and `is_default`. To change only the template or categories, leave `schedules` out of the replace.
* **Limits:** the preferences editor allows up to four schedules and five categories. The API has no cap.

Schedule ids look like `sch_01m26nhsf7fzxr5kngwf8p0b2c`. Ids created before that format look like `sch/{uuid}` and must be written as `%2F` in a raw URL. The SDKs escape both.

## How digested items reach the template

A send joins a category by its top-level `data` keys:

* The key is spelled exactly like the category name, case included.
* Its value isn't `null`, `false`, `0`, or an empty string.
* A send with keys for two categories counts in both.
* A send that matches no category isn't held. Courier delivers it immediately as an individual message.
* A category named `digest` collects every send that matches no other category. A topic with no categories collects everything under `digest`.

Each category's **retain** rule picks which items appear: `FIRST`, `LAST`, or `HIGHEST` and `LOWEST` by a `sort_key`, a top-level field of the send's `data` read as a number. The `limit` sets how many, from 1 to 100, with a default of 10. The preferences editor keeps 10. `count` still reports every event, and anything past the limit is discarded rather than carried into the next digest.

Without a `sort_key`, items follow the order Courier collected them: `FIRST` oldest first, `LAST` and `NONE` newest first. Events sent close together, or through both a journey and a direct send, can arrive out of send order. When order matters, send a numeric timestamp on every event and set it as the `sort_key`. With a `sort_key`, `FIRST` and `LOWEST` list the smallest value first, and `LAST` and `HIGHEST` the largest first.

### Show the schedule period

A release also carries `digest_schedule`, so the template can say which period it covers:

```json theme={null}
{
  "digest_schedule": {
    "recurrence": "daily",
    "timezone": "America/Los_Angeles",
    "period_start": "2026-11-16T17:04:27.107Z",
    "period_end": "2026-11-16T17:04:40.297Z"
  }
}
```

`period_start` is the recipient's first held event and `period_end` is the release, read as `{{data.digest_schedule.period_start}}` in a strict template.

## Release or inspect a digest

To release one recipient, use the call in [Verify](#verify). To release everyone on a schedule, use [`POST /digests/schedules/{schedule_id}/trigger`](https://www.courier.com/docs/api-reference/digests/release-a-digest-early). To see what is held, use [`GET /digests/schedules/{schedule_id}/instances`](https://www.courier.com/docs/api-reference/digests/list-digest-instances).

## Troubleshooting

| Symptom | Cause | Fix |
| - | - | - |
| Sends deliver one by one, logged `SENT` | The recipient is on Instant, often through an Instant topic default | Check their `digest_schedule_id`, then the topic's default schedule |
| Sends deliver one by one, logged `SENT` | The Send node's template isn't linked to the topic | Choose the topic under **Subscription Topic** in the template's settings, then publish the template |
| One kind of event is never held | Its top-level `data` key doesn't match a category exactly, or the value is empty | Name the key exactly like the category, case included |
| Blank values in the digest or the per-event email | The `data.` prefix doesn't match the template's scope | See [Write the digest template](#write-the-digest-template) |
| Digest rows are blank | The item path skips the category key | Write `$.item.task_updates.task_title`, not `$.item.task_title` |
| Subject `(no subject)` and an empty body | The digest template has no content for that channel | Add content to the digest template and publish it |
| Fewer items than `count` | The category's `limit` dropped the rest | Raise `limit`, up to 100 |
| A user who opted out shows `DIGESTED` | Opt-outs are applied when the digest releases | Nothing to fix: the release is dropped as `UNSUBSCRIBED` |
| Items out of send order | Events sent close together were collected out of order | Send a numeric timestamp and set it as the category's `sort_key` |
| Release returned `204` and nothing arrived | Nothing was held for that recipient, or they were sent to in a tenant | Check the instances list, and pass `tenant_id` |
| The previous digest template renders | The digest started before the switch, or the edit isn't published | Publish the template. The next digest uses it |
