Developer ToolsFree generatorPDF, Excel, Word export

WhatsApp Cloud API Send Template Request Generator

Sending a WhatsApp template from an ERP event is one authenticated POST to the Graph API. This generator builds the curl command, the matching Python script and the expected response so you can test a template before wiring it into your integration.

Fill in

Use the version your app is on.

Generated code
Download:

curl

curl -X POST "https://graph.facebook.com/v21.0/123456789012345/messages" \
  -H "Authorization: Bearer $WHATSAPP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "messaging_product": "whatsapp",
    "to": "919800000000",
    "type": "template",
    "template": {
      "name": "shipment_update",
      "language": { "code": "en_US" },
      "components": [
        {
          "type": "body",
          "parameters": [
            { "type": "text", "text": "SO-104522" },
            { "type": "text", "text": "21 Oct 2026" },
            { "type": "text", "text": "https://example.com/track/ABC123" }
          ]
        }
      ]
    }
  }'

Python (requests)

import os
import requests

url = "https://graph.facebook.com/v21.0/123456789012345/messages"
headers = {
    "Authorization": "Bearer " + os.environ["WHATSAPP_TOKEN"],
    "Content-Type": "application/json",
}
payload = {
    "messaging_product": "whatsapp",
    "to": "919800000000",
    "type": "template",
    "template": {
        "name": "shipment_update",
        "language": {"code": "en_US"},
        "components": [
            {
                "type": "body",
                "parameters": [
                    {"type": "text", "text": "SO-104522"},
                    {"type": "text", "text": "21 Oct 2026"},
                    {"type": "text", "text": "https://example.com/track/ABC123"},
                ],
            }
        ],
    },
}

resp = requests.post(url, headers=headers, json=payload, timeout=15)
print(resp.status_code, resp.text)

Expected success response shape

{
  "messaging_product": "whatsapp",
  "contacts": [ { "input": "919800000000", "wa_id": "919800000000" } ],
  "messages": [ { "id": "wamid.XXXXXXXX" } ]
}

The template name and language code must match an approved template exactly, and the number of body parameters must equal the number of variables in the template. Keep the access token in an environment variable or secret store. A success response means the message was accepted, not delivered; track delivery through webhook status events. Verify the endpoint and version against current Meta documentation.

ERP to WhatsApp review

Optional review of how your ERP events map to templates and consent records.

Optional. The tool and every export work without this. No spam.

How to use it

Enter your phone number ID from the WhatsApp Manager, the recipient in international digit format, and the exact name and language code of an approved template. Add the values for each body variable in order. Copy the curl command, export WHATSAPP_TOKEN with a system user access token, and run it. A 200 response with a message ID means Meta accepted the request.

  • Recipient numbers use digits only, with country code and no plus sign.
  • Variables fill {{1}}, {{2}}, {{3}} in the template body in order.
  • Use a permanent system user token for anything beyond testing.

Anatomy of the payload

The messaging_product field is always whatsapp. The type is template, and the template object holds the name, the language code and a components array. A body component carries the ordered parameters. Header, button and media components are added as extra items in the same array when the template defines them. A mismatch between this structure and the approved template returns a 132000 series error.

From ERP event to message

In production the call is made by a worker reading from a queue, not directly in the transaction that posted the shipment. The worker maps ERP fields to variables, checks the customer's opt-in record, sends the request, stores the returned message ID against the order, and later updates status from webhook events.

Common mistakes

Using the phone number itself instead of the phone number ID in the URL is very common. Another is using en when the template was approved in en_US. Sending newline characters or tabs inside a text variable can be rejected by template rules, so clean values first.

Frequently Asked Questions

What is the WhatsApp Cloud API endpoint for sending messages?

It is a POST to https://graph.facebook.com/{version}/{phone-number-id}/messages with a bearer token and a JSON body. The version segment should match the Graph API version your app uses.

Why does my template send return an error about parameters?

The number or type of parameters does not match the approved template. Count the variables in the template body, header and buttons and send exactly that many components in order.

Does a 200 response mean the customer got the message?

No. It means the request was accepted. Delivery and read states arrive later as status events on your webhook, and a message can still fail afterwards, for example if the recipient is unreachable.

Can I send to a number that has not opted in?

You should not. Business messaging policy requires opt-in, and sending to people who have not agreed harms quality rating and can lead to restrictions. Store consent evidence with each contact.

If you want ERP events sent as WhatsApp messages with consent checks, retries and status tracking, Netray can build and operate that pipeline.