POST /api/template-channels Create a new template-channel record that defines the content delivered through a specific channel for a given template.

Headers

appid
string
required
Your CometChat App ID.
apikey
string
required
Your CometChat API Key.

Request body

templateId
string
required
The template ID to link.
channelId
string
required
The channel ID to link.
channelType
string
required
Channel type: in_app, push, sms, email, whatsapp, or custom.
content
object
required
The per-channel content object. Use {{variableName}} placeholders for dynamic values.

Example request

curl -X POST https://{appId}.api-{region}.cometchat.io/v3/business-messaging/api/template-channels \
  -H "appid: YOUR_APP_ID" \
  -H "apikey: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "templateId": "665b2c3d4e5f6a7b8c9d0e1f",
    "channelId": "664a1b2c3d4e5f6a7b8c9d0e",
    "channelType": "in_app",
    "content": {
      "title": "Hello {{customerName}}",
      "body": "Your order {{orderId}} has been confirmed.",
      "actionUrl": "{{viewOrderUrl}}"
    }
  }'

Example response

{
  "templateId": "665b2c3d4e5f6a7b8c9d0e1f",
  "channelId": "664a1b2c3d4e5f6a7b8c9d0e",
  "channelType": "in_app",
  "content": {
    "title": "Hello {{customerName}}",
    "body": "Your order {{orderId}} has been confirmed.",
    "actionUrl": "{{viewOrderUrl}}"
  },
  "createdAt": "2024-01-15T09:30:00.000Z",
  "updatedAt": "2024-01-15T09:30:00.000Z"
}
The content object structure is flexible and varies by channel type. For push channels, include title and body. For email channels, include subject and html or text.