Send notifications to tenant members, individual users with tenant context, multiple recipients, or across tenant hierarchies.
When you send with a tenant context, Courier automatically applies the tenant’s metadata, preferences, branding, and provider credentials to every notification. You can target:
All tenant members with a single tenant_id in to
Individual users with explicit tenant context
Multiple users with shared or per-recipient tenant context
Tenant hierarchies using include_children or include_parent
Set context.tenant_id on a recipient to attach tenant metadata, preferences, and branding to their notification:
Copy
Ask AI
{ "to": { "user_id": "user1", "context": { "tenant_id": "tenantA" } }, "content": { "title": "Hello, {first_name}!", "body": "Brought to you by {$.tenant.name}" }, "routing": { "method": "single", "channels": ["inbox"] }}
This sends to user1 with tenantA’s preferences, branding, and metadata. User-level preferences and data take precedence over tenant values.
A user doesn’t need to be a tenant member to receive a notification with tenant context. This is useful when tenants hold provider credentials or metadata but you don’t need fan-out to all members.
When sending to an array of users, you can set a shared tenant context at the message level with message.context.tenant_id. Every recipient inherits that context.
You can override the message-level tenant for specific recipients by setting context.tenant_id on individual entries in the to array. Per-recipient context takes precedence over the message-level context.
Courier auto-infers tenant context for users who belong to exactly one tenant. For users with multiple memberships, you must specify tenant_id explicitly; otherwise Courier returns a "Tenant Context Not Found" error.
When using Courier Create templates with the tenant/<template_id> format, tenant is the literal word, not your tenant ID. Your actual tenant ID goes in context.tenant_id.
Rules of thumb:
Single-tenant users: tenant context is auto-inferred; specifying it is optional
To fan out upward through the hierarchy, set include_parent: true:
Copy
Ask AI
{ "to": { "tenant_id": "ChildTenantA2", "include_parent": true }, "content": { "title": "Hello, {first_name}!", "body": "Brought to you by {$.tenant.name}" }, "routing": { "method": "single", "channels": ["inbox"] }}
Given the same hierarchy, Courier fans out to User2, User3, and User4. User1 isn’t in the chain upward from ChildTenantA2, and User5 is in a child tenant (not a parent):