Template Creation API

Create and submit WhatsApp message templates to Meta via API key. Templates are always submitted for review immediately — the API returns PENDING. Poll the status endpoint until APPROVED or REJECTED, then send with POST /api/external/send-message.

Prerequisites

  • Active API key
  • Automation permission on the WABA (required for all create endpoints)

Endpoints

MethodPathPurpose
POST/templatesCreate standard text/media template
GET/templates/:templateId/statusPoll Meta approval status
POST/templates/:templateId/syncForce sync from Meta
POST/templates/carouselCreate carousel template

Listing approved templates: GET /templates?status=APPROVED (read-only, no automation required).

Create standard template

Accepts application/json or multipart/form-data.

curl -X POST https://chatyug.com/api/external/templates \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "templateName": "order_update_api",
    "templateContent": "Hi {{1}}, your order {{2}} is confirmed.",
    "category": "UTILITY",
    "language": "en",
    "variables": [
      { "index": 1, "example": "Rahul" },
      { "index": 2, "example": "ORD-991" }
    ]
  }'

Response

{
  "success": true,
  "data": {
    "templateId": 128,
    "metaTemplateId": "123456789",
    "status": "PENDING",
    "statusEndpoint": "/api/external/templates/128/status"
  }
}

Media headers

  • multipart: include mediaFile field and mediaType (IMAGE, VIDEO, DOCUMENT). Requires phoneNumberId for upload to Meta.
  • assetHandle: pass Meta Resumable Upload handle in JSON (recommended for VIDEO).
  • mediaHandle: alternative handle field for pre-uploaded media.

Approval lifecycle

  1. POST /templates → status PENDING
  2. Poll GET /templates/:templateId/status every few minutes
  3. Optionally POST /templates/:templateId/sync to force Meta refresh
  4. When APPROVED, use GET /templates and POST /send-message
Note: ChatYug does not push webhook events when template approval status changes in v1. Poll the status endpoint from your integration.

Create carousel template

curl -X POST https://chatyug.com/api/external/templates/carousel \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "phoneNumberId": "YOUR_PHONE_NUMBER_ID",
    "templateName": "summer_sale_carousel",
    "languageCode": "en_US",
    "bodyText": "Swipe to explore our summer collection",
    "cards": [
      {
        "headerSrc": "https://example.com/card1.jpg",
        "bodyText": "T-shirt",
        "buttons": [{ "type": "URL", "text": "Shop", "url": "https://example.com" }]
      }
    ]
  }'

Once approved, send with POST /api/external/messages/carousel.