Skip to content
Whats91

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

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
ParameterTypeRequiredDescription
messaging_productstringRequiredMust be whatsapp.
tostringRequiredRecipient WhatsApp phone number.
typestringRequiredSet to template.
template.namestringRequiredApproved template name.
template.language.codestringRequiredTemplate language code, such as en or en_US.
template.componentsarrayOptionalMeta-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 '{
  "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({
    "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([
    "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={
        "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 System.Text;

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(
  """
  {
    "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