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
| Method | Path | Purpose |
|---|---|---|
| POST | /templates | Create standard text/media template |
| GET | /templates/:templateId/status | Poll Meta approval status |
| POST | /templates/:templateId/sync | Force sync from Meta |
| POST | /templates/carousel | Create 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
mediaFilefield andmediaType(IMAGE, VIDEO, DOCUMENT). RequiresphoneNumberIdfor upload to Meta. - assetHandle: pass Meta Resumable Upload handle in JSON (recommended for VIDEO).
- mediaHandle: alternative handle field for pre-uploaded media.
Approval lifecycle
POST /templates→ statusPENDING- Poll
GET /templates/:templateId/statusevery few minutes - Optionally
POST /templates/:templateId/syncto force Meta refresh - When
APPROVED, useGET /templatesandPOST /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.