Send Meta-compatible template messages with language and components objects.
Meta-Compatible Template
Summary
Send Meta-compatible template messages with language and components objects.
Prerequisites
- Authorization: Bearer w91_live_xxx
- Content-Type: application/json for JSON requests
Related documentation
Use a Meta-style template object with name, language, and components. Body, header, and button parameters should follow the Meta Cloud API component structure.
POST
/api/v2/messages| Parameter | Type | Required | Description |
|---|---|---|---|
messaging_product | string | Required | Must be whatsapp. |
to | string | Required | Recipient WhatsApp phone number. |
type | string | Required | Set to template. |
template.name | string | Required | Approved template name. |
template.language.code | string | Required | Template language code, such as en or en_US. |
template.components | array | Optional | Meta-style component array containing header, body, or button parameters. |
curl
curl -X POST "https://graph.whats91.com/api/v2/messages" \
-H "Authorization: Bearer w91_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"senderId": "919999999999",
"messaging_product": "whatsapp",
"to": "918888888888",
"type": "template",
"template": {
"name": "payment_reminder",
"language": { "code": "en" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "Devendar" },
{ "type": "text", "text": "INV-1001" }
]
}
]
}
}'SDK Examples
Use these examples as starting points for server-side implementations.
cURL
curl -X POST "https://graph.whats91.com/api/v2/messages" \
-H "Authorization: Bearer w91_live_xxx" \
-H "Content-Type: application/json" \
-d 'curl -X POST "https://graph.whats91.com/api/v2/messages" \
-H "Authorization: Bearer w91_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"senderId": "919999999999",
"messaging_product": "whatsapp",
"to": "918888888888",
"type": "template",
"template": {
"name": "payment_reminder",
"language": { "code": "en" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "Devendar" },
{ "type": "text", "text": "INV-1001" }
]
}
]
}
}''Node.js
const response = await fetch("https://graph.whats91.com/api/v2/messages", {
method: "POST",
headers: {
"Authorization": "Bearer w91_live_xxx",
"Content-Type": "application/json"
},
body: JSON.stringify(curl -X POST "https://graph.whats91.com/api/v2/messages" \
-H "Authorization: Bearer w91_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"senderId": "919999999999",
"messaging_product": "whatsapp",
"to": "918888888888",
"type": "template",
"template": {
"name": "payment_reminder",
"language": { "code": "en" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "Devendar" },
{ "type": "text", "text": "INV-1001" }
]
}
]
}
}')
});
const data = await response.json();
console.log(data);PHP
$ch = curl_init("https://graph.whats91.com/api/v2/messages");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer w91_live_xxx",
"Content-Type: application/json"
],
CURLOPT_POSTFIELDS => json_encode(curl -X POST "https://graph.whats91.com/api/v2/messages" \
-H "Authorization: Bearer w91_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"senderId": "919999999999",
"messaging_product": "whatsapp",
"to": "918888888888",
"type": "template",
"template": {
"name": "payment_reminder",
"language": { "code": "en" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "Devendar" },
{ "type": "text", "text": "INV-1001" }
]
}
]
}
}')
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;Python
import requests
response = requests.request(
"POST",
"https://graph.whats91.com/api/v2/messages",
headers={
"Authorization": "Bearer w91_live_xxx",
"Content-Type": "application/json",
},
json=curl -X POST "https://graph.whats91.com/api/v2/messages" \
-H "Authorization: Bearer w91_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"senderId": "919999999999",
"messaging_product": "whatsapp",
"to": "918888888888",
"type": "template",
"template": {
"name": "payment_reminder",
"language": { "code": "en" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "Devendar" },
{ "type": "text", "text": "INV-1001" }
]
}
]
}
}'
)
print(response.json())C#
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer w91_live_xxx");
var request = new HttpRequestMessage(HttpMethod.Post, "https://graph.whats91.com/api/v2/messages");
request.Content = new StringContent(
"""curl -X POST \"https://graph.whats91.com/api/v2/messages\" \
-H \"Authorization: Bearer w91_live_xxx\" \
-H \"Content-Type: application/json\" \
-d '{
\"senderId\": \"919999999999\",
\"messaging_product\": \"whatsapp\",
\"to\": \"918888888888\",
\"type\": \"template\",
\"template\": {
\"name\": \"payment_reminder\",
\"language\": { \"code\": \"en\" },
\"components\": [
{
\"type\": \"body\",
\"parameters\": [
{ \"type\": \"text\", \"text\": \"Devendar\" },
{ \"type\": \"text\", \"text\": \"INV-1001\" }
]
}
]
}
}'""",
Encoding.UTF8,
"application/json"
);
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());Related APIs
Messaging Meta-Compatibility
Understand the Meta-compatible JSON message sending endpoints exposed through Whats91.
Text
Send Meta-compatible text messages through the Whats91 public API.
Media
Send Meta-compatible image, video, audio, document, and sticker message payloads.
Interactive
Send Meta-compatible interactive button and list payloads.