Templates Endpoints
Manage WhatsApp message templates including creation, synchronization, sending, and deletion.
Overview
Templates must be approved by WhatsApp before they can be used for messaging. Use the sync endpoint to fetch approved templates from WhatsApp Business API.
Endpoints Summary
| Method | Endpoint | Description |
|---|---|---|
| GET | /templates | List templates |
| POST | /templates/sync | Sync from WhatsApp |
| POST | /templates | Create a template |
| DELETE | /templates/{id} | Delete a template |
| POST | /templates/send | Send a template message |
List Templates
Retrieve all templates for a specific inbox.
Query Parameters
The inbox ID to filter templates
Filter by status: approved, pending, rejected
Maximum results (default: 50)
Pagination offset
curl -X GET "https://api.cekat.ai/templates?inbox_id=inbox_abc123&status=approved" \
-H "Authorization: Bearer YOUR_API_KEY"
Response
{
"success": true,
"data": [
{
"id": "tmpl_abc123",
"wa_template_id": "6389027167578912",
"name": "welcome_message",
"category": "UTILITY",
"status": "approved",
"language": "en",
"components": [
{
"type": "BODY",
"text": "Welcome {{1}}! Thanks for reaching out."
}
],
"created_at": "2025-03-01T10:00:00Z"
}
]
}
Sync Templates
Fetch templates from WhatsApp Business API and sync with CekatAI database.
curl -X POST "https://api.cekat.ai/templates/sync?inbox_id=inbox_abc123" \
-H "Authorization: Bearer YOUR_API_KEY"
Response
{
"success": true,
"data": {
"synced": 12,
"new": 3,
"updated": 5,
"deleted": 1
}
}
Create Template
Create a new message template.
Request Body
Inbox ID where the template will be used
Template name (lowercase, underscores only)
Category: UTILITY, MARKETING, or AUTHENTICATION
Language code: en, id, ms, etc.
Array of template components (HEADER, BODY, FOOTER, BUTTONS)
curl -X POST "https://api.cekat.ai/templates" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"inbox_id": "inbox_abc123",
"name": "order_confirmation",
"category": "UTILITY",
"language": "en",
"components": [
{
"type": "HEADER",
"format": "TEXT",
"text": "Order Confirmation"
},
{
"type": "BODY",
"text": "Hi {{1}}, your order #{{2}} has been confirmed. Total: {{3}}"
},
{
"type": "BUTTONS",
"buttons": [
{
"type": "URL",
"text": "Track Order",
"url": "https://example.com/track/{{2}}"
}
]
}
]
}'
Response
{
"success": true,
"data": {
"id": "tmpl_xyz789",
"wa_template_id": "1234567890123456",
"name": "order_confirmation",
"status": "pending",
"created_at": "2025-03-27T14:30:00Z"
}
}
Delete Template
Delete a template from WhatsApp Business API.
curl -X DELETE "https://api.cekat.ai/templates/6389027167578912" \
-H "Authorization: Bearer YOUR_API_KEY"
Response
{
"success": true,
"message": "Template deleted successfully"
}
Send Template Message
Send a template message to a customer via WhatsApp.
Request Body
Source inbox ID
Recipient phone number in E.164 format
Name of the approved template
Template language code
Variable values for template placeholders
curl -X POST "https://api.cekat.ai/templates/send" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"inbox_id": "inbox_abc123",
"to": "+62812345678",
"template_name": "order_confirmation",
"language": "en",
"components": {
"body": {
"parameters": [
{ "type": "text", "text": "John" },
{ "type": "text", "text": "ORD-12345" },
{ "type": "text", "text": "$99.00" }
]
}
}
}'
Response
{
"success": true,
"data": {
"message_id": "msg_abc123",
"status": "sent",
"to": "+62812345678",
"timestamp": "2025-03-27T15:00:00Z"
}
}
Code Examples
// List templates
const listTemplates = async (inboxId, status = 'approved') => {
const response = await fetch(
`https://api.cekat.ai/templates?inbox_id=${inboxId}&status=${status}`,
{ headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }
);
return response.json();
};
// Send template message
const sendTemplate = async (inboxId, to, templateName, params) => {
const response = await fetch('https://api.cekat.ai/templates/send', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
inbox_id: inboxId,
to,
template_name: templateName,
language: 'en',
components: {
body: { parameters: params }
}
})
});
return response.json();
};
