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

# Tenant default preferences

> Set each topic's starting status for everyone in a tenant, in the console or with the API. Users can still change their own unless the topic is REQUIRED.

> [!NOTE]
>
> [How preferences resolve](https://www.courier.com/docs/recipients/preferences/overview.md) and [how tenant context works](https://www.courier.com/docs/tenants/context.md) cover the concepts behind this page.

Preferences are usually the first reason people reach for tenants. A customer's admin wants a category of notification switched off across their whole company, and that has to hold for users who never open a preference center.

A tenant default sets a topic's starting state for everyone in that organization. It overrides the workspace default for any send that names the tenant, and each user can still change their own from there.

**A tenant default isn't a way to force a setting.** A user who opts out stays opted out, because their own preference sits below the tenant's in the [merge order](https://www.courier.com/docs/recipients/preferences/overview.md#status-precedence). Mark a topic `REQUIRED` when it is transactional and nobody should be able to switch it off, which is the only status that ignores what the user chose.

> [!NOTE]
>
> A tenant default sets a topic's **status** and nothing else. Channel routing is read from each user's own preference record. A tenant's `has_custom_routing` and `custom_routing` have no effect at send time, even though the API accepts and returns them, so a tenant that looks correctly configured can route nothing. To route a topic to specific channels, set it on the [user's preferences](https://www.courier.com/docs/recipients/preferences/api.md).

## Prerequisites

* [A tenant under Directory → Tenants](https://app.courier.com/directory/tenants)
* [The tenant model](https://www.courier.com/docs/tenants/overview.md)
* [Your subscription topics under Platform → Preferences](https://app.courier.com/~/test/platform/preferences)
* [The status precedence rules](https://www.courier.com/docs/recipients/preferences/overview.md#status-precedence)

## Set tenant defaults

**1. Set defaults in the console**

In the console, a tenant stores its defaults as a single `default_preferences` JSON object that you edit directly. Go to the tenant in the [console](https://app.courier.com/directory/tenants) (**Directory → Tenants**) and open its **Details** tab. In the **Default Preferences** section, paste a JSON object whose `items` array holds one entry per topic. Each entry takes the `topic_id` as `id` and a `status` of `OPTED_IN`, `OPTED_OUT`, or `REQUIRED`. Save.

![A tenant's Details tab with the Default Preferences JSON editor holding three topic entries and reporting Valid JSON](https://mintcdn.com/courier-4f1f25dc/rYENcCCTyPPrDtw0/assets/tenant-default-preferences.webp?fit=max\&auto=format\&n=rYENcCCTyPPrDtw0\&q=85\&s=275ba127bd82e12171112f9077d377cc)

The Default Preferences JSON editor on a tenant's Details tab in the console.

This example opts one topic in, makes a second impossible to turn off, and opts out of a third. Topics you leave out keep their workspace default:

```json theme={null}
{
  "items": [
    {
      "id": "pt_01kx4h2jdafq8bk996nn92357r",
      "status": "OPTED_IN"
    },
    {
      "id": "pt_01kx4h9m2rdvc7yq5tb8n30k4e",
      "status": "REQUIRED"
    },
    {
      "id": "pt_01kx4hb7t8fzs2mp6wc4j91xgd",
      "status": "OPTED_OUT"
    }
  ]
}
```

**2. Set a default with the API**

[`PUT /tenants/{tenant_id}/default_preferences/items/{topic_id}`](https://www.courier.com/docs/api-reference/tenants/create-or-replace-default-preferences-for-topic) sets tenant defaults one topic at a time from your backend. Only the topics you include override the workspace default. Topics you leave out fall back to their workspace default state. The same `default_preferences` object shown above is what you send when you create or replace the tenant through the [Tenants API](https://www.courier.com/docs/api-reference/tenants/create-or-replace-a-tenant.md). Set one topic's default with a body shaped like a topic, carrying its `status`.

```javascript Node.js highlight={9} theme={null}
import Courier from '@trycourier/courier';

const client = new Courier({
  apiKey: process.env['COURIER_API_KEY'],
});

await client.tenants.preferences.items.update('pt_01kx4h2jdafq8bk996nn92357r', {
  tenant_id: 'acme-corp',
  status: 'OPTED_IN',
});
```

```python Python highlight={10} theme={null}
import os
from courier import Courier

client = Courier(
    api_key=os.environ.get("COURIER_API_KEY"),
)
client.tenants.preferences.items.update(
    topic_id="pt_01kx4h2jdafq8bk996nn92357r",
    tenant_id="acme-corp",
    status="OPTED_IN",
)
```

```bash cURL highlight={4} theme={null}
curl -X PUT https://api.courier.com/tenants/acme-corp/default_preferences/items/pt_01kx4h2jdafq8bk996nn92357r \
  -H "Authorization: Bearer $COURIER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "status": "OPTED_IN" }'
```

```ruby Ruby highlight={5} theme={null}
require "courier"

courier = Courier::Client.new(api_key: ENV["COURIER_API_KEY"])

result = courier.tenants.preferences.items.update("pt_01kx4h2jdafq8bk996nn92357r", tenant_id: "acme-corp", status: :OPTED_IN)

puts(result)
```

```go Go highlight={7} theme={null}
err := client.Tenants.Preferences.Items.Update(
	context.TODO(),
	"pt_01kx4h2jdafq8bk996nn92357r",
	courier.TenantPreferenceItemUpdateParams{
		TenantID: "acme-corp",
		SubscriptionTopicNew: courier.SubscriptionTopicNewParam{
			Status: courier.SubscriptionTopicNewStatusOptedIn,
		},
	},
)
```

```java Java highlight={5} theme={null}
ItemUpdateParams params = ItemUpdateParams.builder()
    .tenantId("acme-corp")
    .topicId("pt_01kx4h2jdafq8bk996nn92357r")
    .subscriptionTopicNew(SubscriptionTopicNew.builder()
        .status(SubscriptionTopicNew.Status.OPTED_IN)
        .build())
    .build();
client.tenants().preferences().items().update(params);
```

```php PHP highlight={4} theme={null}
$result = $client->tenants->preferences->items->update(
  'pt_01kx4h2jdafq8bk996nn92357r',
  tenantID: 'acme-corp',
  status: 'OPTED_IN',
);
```

```csharp C# highlight={5} theme={null}
ItemUpdateParams parameters = new()
{
    TenantID = "acme-corp",
    TopicID = "pt_01kx4h2jdafq8bk996nn92357r",
    Status = Status.OptedIn,
};

await client.Tenants.Preferences.Items.Update(parameters);
```

```bash CLI highlight={5} theme={null}
courier tenants:preferences:items update \
  --api-key "$COURIER_API_KEY" \
  --tenant-id acme-corp \
  --topic-id pt_01kx4h2jdafq8bk996nn92357r \
  --status OPTED_IN
```

```text MCP theme={null}
With Courier MCP, opt acme-corp into that topic by default.
```

**3. Remove a tenant default**

[`DELETE /tenants/{tenant_id}/default_preferences/items/{topic_id}`](https://www.courier.com/docs/api-reference/tenants/remove-default-preferences-for-topic) removes a tenant default for a topic, reverting it to the workspace default:

```javascript Node.js theme={null}
import Courier from '@trycourier/courier';

const client = new Courier({
  apiKey: process.env['COURIER_API_KEY'],
});

await client.tenants.preferences.items.delete('pt_01kx4h2jdafq8bk996nn92357r', { tenant_id: 'acme-corp' });
```

```python Python theme={null}
import os
from courier import Courier

client = Courier(
    api_key=os.environ.get("COURIER_API_KEY"),
)
client.tenants.preferences.items.delete(
    topic_id="pt_01kx4h2jdafq8bk996nn92357r",
    tenant_id="acme-corp",
)
```

```bash cURL theme={null}
curl -X DELETE https://api.courier.com/tenants/acme-corp/default_preferences/items/pt_01kx4h2jdafq8bk996nn92357r \
  -H "Authorization: Bearer $COURIER_API_KEY"
```

```ruby Ruby theme={null}
require "courier"

courier = Courier::Client.new(api_key: ENV["COURIER_API_KEY"])

result = courier.tenants.preferences.items.delete("pt_01kx4h2jdafq8bk996nn92357r", tenant_id: "acme-corp")

puts(result)
```

```go Go theme={null}
err := client.Tenants.Preferences.Items.Delete(
	context.TODO(),
	"pt_01kx4h2jdafq8bk996nn92357r",
	courier.TenantPreferenceItemDeleteParams{
		TenantID: "acme-corp",
	},
)
```

```java Java theme={null}
ItemDeleteParams params = ItemDeleteParams.builder()
    .tenantId("acme-corp")
    .topicId("pt_01kx4h2jdafq8bk996nn92357r")
    .build();
client.tenants().preferences().items().delete(params);
```

```php PHP theme={null}
$result = $client->tenants->preferences->items->delete(
  'pt_01kx4h2jdafq8bk996nn92357r', tenantID: 'acme-corp'
);
```

```csharp C# theme={null}
ItemDeleteParams parameters = new()
{
    TenantID = "acme-corp",
    TopicID = "pt_01kx4h2jdafq8bk996nn92357r",
};

await client.Tenants.Preferences.Items.Delete(parameters);
```

```bash CLI theme={null}
courier tenants:preferences:items delete \
  --api-key "$COURIER_API_KEY" \
  --tenant-id acme-corp \
  --topic-id pt_01kx4h2jdafq8bk996nn92357r
```

```text MCP theme={null}
With Courier MCP, remove acme-corp's default for that topic.
```

**4. Read the defaults back**

Read the tenant back to confirm its defaults. The `default_preferences` field on the returned tenant holds the topics you set. Call the [get tenant endpoint](https://www.courier.com/docs/api-reference/tenants/get-a-tenant.md):

```javascript Node.js theme={null}
import Courier from '@trycourier/courier';

const client = new Courier({
  apiKey: process.env['COURIER_API_KEY'],
});

const tenant = await client.tenants.retrieve('acme-corp');

console.log(tenant.default_preferences);
```

```python Python theme={null}
import os
from courier import Courier

client = Courier(
    api_key=os.environ.get("COURIER_API_KEY"),
)
tenant = client.tenants.retrieve("acme-corp")
print(tenant.default_preferences)
```

```bash cURL theme={null}
curl -X GET https://api.courier.com/tenants/acme-corp \
  -H "Authorization: Bearer $COURIER_API_KEY"
```

```ruby Ruby theme={null}
require "courier"

courier = Courier::Client.new(api_key: ENV["COURIER_API_KEY"])

tenant = courier.tenants.retrieve("acme-corp")

puts(tenant.default_preferences)
```

```go Go theme={null}
tenant, err := client.Tenants.Get(context.TODO(), "acme-corp")
```

```java Java theme={null}
Tenant tenant = client.tenants().retrieve("acme-corp");
```

```php PHP theme={null}
$tenant = $client->tenants->retrieve('acme-corp');
```

```csharp C# theme={null}
TenantRetrieveParams parameters = new() { TenantID = "acme-corp" };

var tenant = await client.Tenants.Retrieve(parameters);
```

```bash CLI theme={null}
courier tenants retrieve \
  --api-key "$COURIER_API_KEY" \
  --tenant-id acme-corp
```

```text MCP theme={null}
With Courier MCP, show me acme-corp's tenant settings and default preferences.
```

**5. Verify the tenant default**

Pick a user with no preference set for the Topic. Send them a message mapped to it in the Tenant's context, including `tenant_id`. Confirm delivery follows the Tenant default, not the workspace default.

## How tenant defaults apply

* **A user's preference read shows the topic default, not the tenant's.** The call returns the topic-level `default_status` even when [scoped to the tenant](https://www.courier.com/docs/recipients/preferences/api.md#scope-to-a-tenant). Read the tenant itself for its defaults, and use a test send to confirm what a user receives.
* **A tenant default applies to sends that carry the tenant.** A send without `tenant_id` uses the workspace default, unless auto-infer resolves the tenant for you.
