> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> Create a new template.

# Create a new template



## OpenAPI

````yaml post /templates
openapi: 3.0.0
info:
  title: Campaigns Service API
  description: Campaigns Service REST API
  version: '1.0'
  contact: {}
servers:
  - url: https://{appId}.api-{region}.cometchat.io/v3/campaigns
    variables:
      appId:
        default: appId
        description: (Required) App ID
      region:
        enum:
          - us
          - eu
          - in
        default: us
        description: Select Region
security:
  - apikey: []
tags:
  - name: Notification Feed
    description: Operations on the per-user in-app notification feed.
  - name: Channels
    description: Manage channel instances and per-type availability.
  - name: Templates
    description: Manage templates and their versions.
  - name: Template Categories
    description: Manage template categories for feed filtering.
  - name: Campaigns
    description: Create, schedule, and manage notification campaigns.
  - name: Notifications
    description: Send notifications directly via API.
  - name: Push Notifications
    description: Manage push notification delivery and engagement.
  - name: Analytics
    description: Delivery and engagement analytics.
paths:
  /templates:
    post:
      tags:
        - Templates
      summary: Create a new template
      operationId: TemplatesController_create
      parameters:
        - name: appid
          in: header
          description: Tenant application ID
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTemplateDto'
      responses:
        '201':
          description: Template created
        '400':
          description: Invalid input or variable schema
        '409':
          description: Duplicate channel type
components:
  schemas:
    CreateTemplateDto:
      type: object
      properties:
        name:
          type: string
          description: Template name
        templateId:
          type: string
          description: Human-readable slug (auto-generated from name if omitted)
        templateCategory:
          type: string
          description: Template category
          enum:
            - Onboarding
            - Transactional
            - Marketing
            - Product_Showcase
            - Alerts
            - Polls
            - Custom
        label:
          type: string
          description: Display label shown on notification (e.g. Promo, Alert)
        alternativeText:
          type: string
          description: >-
            Plain-text fallback when push is suppressed or rich content cannot
            render. Sendbird-parity field.
        tags:
          description: First-class tags for filtering/segmentation
          type: array
          items:
            type: string
        status:
          type: string
          description: Template status
          enum:
            - draft
            - approved
            - archived
        channels:
          description: Channel configurations
          type: array
          items:
            $ref: '#/components/schemas/ChannelContentDto'
        variableSchema:
          description: Variable schema definitions
          type: array
          items:
            type: object
        config:
          type: object
          description: Additional configuration
      required:
        - name
        - channels
    ChannelContentDto:
      type: object
      properties:
        channelId:
          type: string
          description: Channel instance ID (links to Channel entity)
        channelType:
          type: string
          description: Channel type identifier
        content:
          type: object
          description: Channel content (defaults applied if omitted)
        dataType:
          type: string
          description: Data type
          enum:
            - ui_template
            - data_template
        categoryFilterEnabled:
          type: boolean
          description: Enable category filter (in-app only)
        templateLabelEnabled:
          type: boolean
          description: Enable template label (in-app only)
        messageRetentionHours:
          type: number
          description: Message retention in hours
        sequenceOrder:
          type: number
          description: Position in sequence (1, 2, 3...)
        stopCondition:
          type: string
          description: >-
            Stop condition for sequence step. Allowed values depend on
            channelType: feed channels (in_app) accept `delivered` | `read` |
            `engaged`; push channels accept `delivered` | `clicked`. Validated
            per-channel at template save (ENG-35239).
        waitMinutes:
          type: number
          description: Wait time in minutes before advancing to next step
          enum:
            - 5
            - 10
            - 30
            - 60
            - 240
            - 1440
      required:
        - channelType
  securitySchemes:
    apikey:
      type: apiKey
      in: header
      name: apikey
      description: Your CometChat REST API Key.

````