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

# Notify everyone watching

> Model watchers of a document or ticket as a list per entity, then notify them in one send, with wildcard list patterns and per-watcher preferences.

Someone comments on a document, and everyone watching it should hear about it. This guide models watchers as a list per entity.

A `list_id` is a dotted namespace, so `document.doc_a1b2.watchers` names the watchers of one document.

## Prerequisites

* [A Courier API key](https://app.courier.com/settings/api-keys)
* A [profile](https://www.courier.com/docs/recipients/overview.md) for each user you subscribe
* A published [template](https://www.courier.com/docs/design/templates/overview.md) to send

## Name the list after the entity

Pick a naming convention before you write any code, because the name is the only thing tying a list to the thing it belongs to. A `list_id` holds up to six dot-separated segments:

```text theme={null}
<entity type>.<entity id>.<relationship>
```

| The thing | The list |
| :- | :- |
| Watchers of a document | `document.doc_a1b2.watchers` |
| Members of a project | `project.proj_9f3e.members` |
| Subscribers to a ticket | `ticket.tkt_77c1.subscribers` |

Keeping the entity type in the first segment is what makes [wildcards](https://www.courier.com/docs/guides/notify-everyone-watching.md#reach-every-entity-of-a-kind) useful later. Entity ids with dots in them won't work, since a dot starts a new segment.

## Wire up watching

**1. Subscribe a user when they start watching**

One call, and it is idempotent. [`PUT /lists/{list_id}/subscriptions/{user_id}`](https://www.courier.com/docs/api-reference/lists/subscribe-a-user-profile-to-a-list) **creates the list if it doesn't exist**, so you never check first.

```javascript Node.js theme={null}
await client.lists.subscriptions.subscribeUser("user_123", {
  list_id: "document.doc_a1b2.watchers",
});
```

```python Python theme={null}
client.lists.subscriptions.subscribe_user(
    "user_123",
    list_id="document.doc_a1b2.watchers",
)
```

```bash cURL theme={null}
curl -X PUT https://api.courier.com/lists/document.doc_a1b2.watchers/subscriptions/user_123 \
  -H "Authorization: Bearer $COURIER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

```ruby Ruby theme={null}
courier.lists.subscriptions.subscribe_user(
  "user_123",
  list_id: "document.doc_a1b2.watchers"
)
```

```go Go theme={null}
err := client.Lists.Subscriptions.SubscribeUser(
	context.TODO(),
	"user_123",
	courier.ListSubscriptionSubscribeUserParams{
		ListID: "document.doc_a1b2.watchers",
	},
)
```

```java Java theme={null}
SubscriptionSubscribeUserParams params = SubscriptionSubscribeUserParams.builder()
    .listId("document.doc_a1b2.watchers")
    .userId("user_123")
    .build();

client.lists().subscriptions().subscribeUser(params);
```

```php PHP theme={null}
$client->lists->subscriptions->subscribeUser(
  'user_123',
  listID: 'document.doc_a1b2.watchers',
);
```

```csharp C# theme={null}
await client.Lists.Subscriptions.SubscribeUser(
    "user_123",
    new() { ListID = "document.doc_a1b2.watchers" }
);
```

```bash CLI theme={null}
courier lists:subscriptions subscribe-user \
  --api-key "$COURIER_API_KEY" \
  --user-id user_123 \
  --list-id document.doc_a1b2.watchers
```

```text MCP theme={null}
With Courier MCP, subscribe user_123 to the list document.doc_a1b2.watchers.
```

Call this wherever your app already records a watch: an explicit **Watch** button, or implicitly when someone comments or is assigned.

**2. Notify everyone watching**

Address the list instead of a user. Courier fans out to every subscriber and applies each recipient's own [preferences](https://www.courier.com/docs/recipients/preferences/overview.md).

```javascript Node.js highlight={3} theme={null}
await client.send.message({
  message: {
    to: { list_id: "document.doc_a1b2.watchers" },
    template: "nt_01kx4h2jdafq8bk9aftxak4b40",
    data: { document_title: "Q3 Roadmap", commenter: "Sarah Bennett" },
  },
});
```

```python Python highlight={3} theme={null}
client.send.message(
    message={
        "to": {"list_id": "document.doc_a1b2.watchers"},
        "template": "nt_01kx4h2jdafq8bk9aftxak4b40",
        "data": {"document_title": "Q3 Roadmap", "commenter": "Sarah Bennett"},
    },
)
```

```bash cURL highlight={6} theme={null}
curl -X POST https://api.courier.com/send \
  -H "Authorization: Bearer $COURIER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "message": {
      "to": { "list_id": "document.doc_a1b2.watchers" },
      "template": "nt_01kx4h2jdafq8bk9aftxak4b40",
      "data": { "document_title": "Q3 Roadmap", "commenter": "Sarah Bennett" }
    }
  }'
```

```ruby Ruby highlight={3} theme={null}
courier.send_.message(
  message: {
    to: {list_id: "document.doc_a1b2.watchers"},
    template: "nt_01kx4h2jdafq8bk9aftxak4b40",
    data: {document_title: "Q3 Roadmap", commenter: "Sarah Bennett"}
  }
)
```

```go Go highlight={5} theme={null}
response, err := client.Send.Message(context.TODO(), courier.SendMessageParams{
	Message: courier.SendMessageParamsMessage{
		To: courier.SendMessageParamsMessageToUnion{
			OfListRecipient: &shared.ListRecipientParam{
				ListID: courier.String("document.doc_a1b2.watchers"),
			},
		},
		Template: courier.String("nt_01kx4h2jdafq8bk9aftxak4b40"),
		Data: map[string]any{
			"document_title": "Q3 Roadmap",
			"commenter":      "Sarah Bennett",
		},
	},
})
```

```java Java highlight={3} theme={null}
SendMessageParams.Message message = SendMessageParams.Message.builder()
    .to(SendMessageParams.Message.To.ofListRecipient(
        ListRecipient.builder().listId("document.doc_a1b2.watchers").build()))
    .template("nt_01kx4h2jdafq8bk9aftxak4b40")
    .data(SendMessageParams.Message.Data.builder()
        .putAdditionalProperty("document_title", JsonValue.from("Q3 Roadmap"))
        .putAdditionalProperty("commenter", JsonValue.from("Sarah Bennett"))
        .build())
    .build();

client.send().message(SendMessageParams.builder().message(message).build());
```

```php PHP highlight={3} theme={null}
$client->send->message(
  message: [
    'to' => ['list_id' => 'document.doc_a1b2.watchers'],
    'template' => 'nt_01kx4h2jdafq8bk9aftxak4b40',
    'data' => ['document_title' => 'Q3 Roadmap', 'commenter' => 'Sarah Bennett'],
  ],
);
```

```csharp C# highlight={5} theme={null}
SendMessageParams parameters = new()
{
    Message = new()
    {
        To = new ListRecipient { ListID = "document.doc_a1b2.watchers" },
        Template = "nt_01kx4h2jdafq8bk9aftxak4b40",
        Data = new()
        {
            ["document_title"] = "Q3 Roadmap",
            ["commenter"] = "Sarah Bennett",
        },
    },
};

var response = await client.Send.Message(parameters);
```

```bash CLI highlight={3} theme={null}
courier send message \
  --api-key "$COURIER_API_KEY" \
  --message.to '{"list_id": "document.doc_a1b2.watchers"}' \
  --message.template nt_01kx4h2jdafq8bk9aftxak4b40 \
  --message.data '{"document_title": "Q3 Roadmap", "commenter": "Sarah Bennett"}'
```

```text MCP theme={null}
With Courier MCP, send the nt_01kx4h2jdafq8bk9aftxak4b40 template to the list document.doc_a1b2.watchers.
```

One send reaches every watcher, however many there are. You don't fan out yourself.

**3. Unsubscribe when they stop watching**

[`DELETE /lists/{list_id}/subscriptions/{user_id}`](https://www.courier.com/docs/api-reference/lists/unsubscribe-a-user-profile-from-a-list) removes one watcher and leaves the rest alone.

```javascript Node.js theme={null}
await client.lists.subscriptions.unsubscribeUser("user_123", {
  list_id: "document.doc_a1b2.watchers",
});
```

```python Python theme={null}
client.lists.subscriptions.unsubscribe_user(
    "user_123",
    list_id="document.doc_a1b2.watchers",
)
```

```bash cURL theme={null}
curl -X DELETE https://api.courier.com/lists/document.doc_a1b2.watchers/subscriptions/user_123 \
  -H "Authorization: Bearer $COURIER_API_KEY"
```

```ruby Ruby theme={null}
courier.lists.subscriptions.unsubscribe_user(
  "user_123",
  list_id: "document.doc_a1b2.watchers"
)
```

```go Go theme={null}
err := client.Lists.Subscriptions.UnsubscribeUser(
	context.TODO(),
	"user_123",
	courier.ListSubscriptionUnsubscribeUserParams{
		ListID: "document.doc_a1b2.watchers",
	},
)
```

```java Java theme={null}
SubscriptionUnsubscribeUserParams params = SubscriptionUnsubscribeUserParams.builder()
    .listId("document.doc_a1b2.watchers")
    .userId("user_123")
    .build();

client.lists().subscriptions().unsubscribeUser(params);
```

```php PHP theme={null}
$client->lists->subscriptions->unsubscribeUser(
  'user_123',
  listID: 'document.doc_a1b2.watchers',
);
```

```csharp C# theme={null}
await client.Lists.Subscriptions.UnsubscribeUser(
    "user_123",
    new() { ListID = "document.doc_a1b2.watchers" }
);
```

```bash CLI theme={null}
courier lists:subscriptions unsubscribe-user \
  --api-key "$COURIER_API_KEY" \
  --user-id user_123 \
  --list-id document.doc_a1b2.watchers
```

```text MCP theme={null}
With Courier MCP, unsubscribe user_123 from the list document.doc_a1b2.watchers.
```

When the entity itself is deleted, delete the whole list with [`DELETE /lists/{list_id}`](https://www.courier.com/docs/api-reference/lists/delete-a-list) rather than removing watchers one at a time.

## Ask who is watching what

Both directions of the relationship are readable, which is what makes this usable as your app's own watch state rather than a write-only copy of it.

| Question | Endpoint |
| :- | :- |
| Who is watching this document? | [`GET /lists/{list_id}/subscriptions`](https://www.courier.com/docs/api-reference/lists/list-subscriptions-for-a-list) |
| What is this user watching? | [`GET /profiles/{user_id}/lists`](https://www.courier.com/docs/api-reference/user-profiles/get-list-subscriptions) |

Both are [cursor-paginated](https://www.courier.com/docs/reference/api-overview.md#pagination).

## Reach every entity of a kind

Because the entity type leads the `list_id`, one pattern can address many lists at once. Swap `list_id` for `list_pattern`, where `*` matches a single segment:

```json theme={null}
{
  "to": { "list_pattern": "document.*.watchers" }
}
```

That reaches everyone watching any document, without you listing them.

> [!NOTE]
>
> A recipient watching several matched entities is deduplicated, so nobody receives the same message twice from one send.

## Per-watcher preferences

A subscription can carry its own `preferences`, which apply to that subscription alone. Someone can follow a noisy project on digest while staying on instant notifications everywhere else. See [preferences](https://www.courier.com/docs/recipients/preferences/overview.md) for the status model.

## Verify

**1. Subscribe two users**

Subscribe two test users to `document.doc_a1b2.watchers`.

**2. Read the list back**

Call [`GET /lists/{list_id}/subscriptions`](https://www.courier.com/docs/api-reference/lists/list-subscriptions-for-a-list) and confirm both appear, which also proves the list was created by the subscribe call.

**3. Send and check the logs**

Send to the list, then open [Logs](https://app.courier.com/logs). You should see one message per subscriber, each with its own status.

**4. Unsubscribe one and send again**

The second send reaches one recipient. The unsubscribed user gets nothing.

## FAQ

> [accordion] Do I have to create the list before subscribing anyone?
>
> Subscribing creates the list when it doesn't exist, so a Watch button is one call with no setup and no existence check.

> [accordion] What happens when a watcher has opted out?
>
> Courier applies each recipient's preferences during fan-out, so an opted-out watcher is filtered and the rest still receive the message. The send doesn't fail.

> [accordion] How many watchers can one list hold?
>
> Lists are built for fan-out, so a busy document with thousands of watchers is one send. Read members back with cursor pagination rather than all at once.

> [accordion] Can I scope this to one tenant?
>
> Add a `MEMBER_OF` filter on the recipient alongside `context.tenant_id`. Tenant context alone sets branding and preferences without restricting who receives the message. See [scoping a list send to a tenant](https://www.courier.com/docs/recipients/lists-and-audiences/lists.md#scoping-a-list-send-to-a-tenant).

> [accordion] Should I use an audience instead?
>
> Use an audience when membership follows from profile data, such as every user on the Pro plan. Watching is an explicit act that no profile field implies, so a list is the right shape.
