PUT /api/templates/{id} Update an existing template. Use this endpoint to change the status from draft to approved, update the variable schema, or modify other template properties.

Headers

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

Path parameters

id
string
required
The template ID.

Request body

name
string
Updated display name.
category
string
Updated category.
status
string
New status: draft, approved, or archived.
availability
string
Template availability setting.
sequence
integer
Display order sequence number.
config
object
Updated template-level configuration.
variableSchema
object
Updated variable declarations. Each key is a variable name with a type of string, image, or action.

Example request

curl -X PUT https://{appId}.api-{region}.cometchat.io/v3/business-messaging/api/templates/665b2c3d4e5f6a7b8c9d0e1f \
  -H "appid: YOUR_APP_ID" \
  -H "apikey: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "status": "approved",
    "variableSchema": {
      "customerName": { "type": "string" },
      "orderId": { "type": "string" },
      "trackingUrl": { "type": "action" }
    }
  }'

Example response

{
  "id": "665b2c3d4e5f6a7b8c9d0e1f",
  "appId": "YOUR_APP_ID",
  "name": "Order Confirmation",
  "templateId": "order-confirmation",
  "status": "approved",
  "category": "transactional",
  "channelIds": ["664a1b2c3d4e5f6a7b8c9d0e"],
  "variableSchema": {
    "customerName": { "type": "string" },
    "orderId": { "type": "string" },
    "trackingUrl": { "type": "action" }
  },
  "config": {},
  "createdAt": "2024-01-15T09:30:00.000Z",
  "updatedAt": "2024-01-16T10:00:00.000Z"
}
To approve a template for sending, set "status": "approved". To retire it, set "status": "archived".