> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-llms-scoped-indexes.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates

> Create reusable notification templates with variables, versioning, and multi-channel support.

A template is a reusable notification design that defines the content, delivery channels, and personalization variables for a notification. Every notification — whether sent via campaign or API — flows through a template.

## Template Properties

| Field | Type | Required | Description |
| - | - | - | - |
| `name` | string | Yes | Display name |
| `templateId` | string | No (auto-generated) | Slug: `cc-template-<name>` (immutable) |
| `templateCategory` | string | No | Category name (e.g., "Marketing") |
| `label` | string | No | Display label shown on notification (e.g., "Promo") |
| `alternativeText` | string | No | Plain-text fallback when rich content can't render |
| `tags` | string\[] | No | Tags for filtering and segmentation |
| `status` | enum | Yes | `draft` \| `approved` \| `archived` |
| `channels` | array | Yes | Channel configurations (at least one) |
| `variableSchema` | array | No | Variable definitions |

## Content Types

| dataType | Description |
| - | - |
| `ui_template` | Visual template designed in the Bubble Builder (drag-and-drop editor) |

## Variables

Variables allow per-recipient personalization in notification content.

* **Syntax**: `{{variable_name}}` in template content
* **Naming**: Letters, numbers, and underscores only (`^[a-zA-Z_][a-zA-Z0-9_]*$`)
* **Type**: Selected from a dropdown with the following options:

| Type | Value Format |
| - | - |
| `string` | Plain text string (e.g., `"Hello World"`) |
| `image` | Object: `{ "url": "https://...", "width": 300, "height": 200 }` — all fields required |
| `action` | Object: `{ "type": "web" or "custom", "data": "https://..." }` — both fields required |

<Note>
  `defaultValue` is only supported for `string` type variables. Image and action variables do not support defaults.
</Note>

* **Resolution**: Per-user values are passed at send time in the `variables` field

## Template Versioning

Templates are versioned to maintain a history of changes:

* Templates start at version 1
* Editing an **approved** template auto-bumps the version (creates a new snapshot)
* You can manually create a version via the "New Version" button
* Campaigns pin to a specific `templateVersion` at send time
* Old versions are immutable — safe for historical reference

To access old versions via API, use [Get Template](/rest-api/campaigns-apis/templates/get-template) — the response includes a `versions` array with all previous versions.

## Channel Configuration

Each template has one or more channel configurations:

| Field | Type | Description |
| - | - | - |
| `channelType` | string | `in_app` \| `push` |
| `channelId` | string | Links to a specific Channel entity |
| `content` | object | Notification content (Bubble Builder JSON or custom) |
| `dataType` | string | `ui_template` |
| `messageRetentionHours` | number | Hours before feed item expires (0 = never) |
| `categoryFilterEnabled` | boolean | Enable category-based filtering in feed |
| `templateLabelEnabled` | boolean | Show label badge on notification |

## Template Statuses

| Status | Description |
| - | - |
| `draft` | Work in progress — cannot be used to send |
| `approved` | Ready to use — can be selected for campaigns and notifications |
| `archived` | Soft-deleted — hidden from lists, not usable |

<Note>
  Only templates with `approved` status can be used to send notifications. Archived templates are hidden and cannot be used.
</Note>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.