# WhatsApp Cloud API Send Template Request Generator

> Source: https://netray.co/tools/whatsapp-cloud-api-send-template-request-generator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Builds the Graph API request, JSON payload and a Python equivalent for sending an approved template with up to three body variables.

## Category

developer

## Audience

- Integration developer
- ERP administrator

## Tool

**Kind:** template

**Output:** code

**Language:** http

**Fields:**

#### Graph API version

**Key:** version

**Type:** text

**Default:** v21.0

**Help:** Use the version your app is on.

#### Phone number ID

**Key:** phone_id

**Type:** text

**Default:** 123456789012345

#### Recipient number (digits with country code)

**Key:** to

**Type:** text

**Default:** 919800000000

#### Template name

**Key:** template

**Type:** text

**Default:** shipment_update

#### Template language code

**Key:** lang

**Type:** text

**Default:** en_US

#### Body variable 1

**Key:** var1

**Type:** text

**Default:** SO-104522

#### Body variable 2

**Key:** var2

**Type:** text

**Default:** 21 Oct 2026

#### Body variable 3

**Key:** var3

**Type:** text

**Default:** https://example.com/track/ABC123

**Blocks:**

#### curl

**Body:** curl -X POST "https://graph.facebook.com/{{version}}/{{phone_id}}/messages" \
  -H "Authorization: Bearer $WHATSAPP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "messaging_product": "whatsapp",
    "to": "{{to}}",
    "type": "template",
    "template": {
      "name": "{{template}}",
      "language": { "code": "{{lang}}" },
      "components": [
        {
          "type": "body",
          "parameters": [
            { "type": "text", "text": "{{var1}}" },
            { "type": "text", "text": "{{var2}}" },
            { "type": "text", "text": "{{var3}}" }
          ]
        }
      ]
    }
  }'

#### Python (requests)

**Body:** import os
import requests

url = "https://graph.facebook.com/{{version}}/{{phone_id}}/messages"
headers = {
    "Authorization": "Bearer " + os.environ["WHATSAPP_TOKEN"],
    "Content-Type": "application/json",
}
payload = {
    "messaging_product": "whatsapp",
    "to": "{{to}}",
    "type": "template",
    "template": {
        "name": "{{template}}",
        "language": {"code": "{{lang}}"},
        "components": [
            {
                "type": "body",
                "parameters": [
                    {"type": "text", "text": "{{var1}}"},
                    {"type": "text", "text": "{{var2}}"},
                    {"type": "text", "text": "{{var3}}"},
                ],
            }
        ],
    },
}

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

#### Expected success response shape

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

**Notes:** 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.

## Content

**Intro:** 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.

**Sections:**

#### How to use it

**Body:** 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.

**Bullets:**

- 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

**Body:** 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

**Body:** 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

**Body:** 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.

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

**Faq:**

#### What is the WhatsApp Cloud API endpoint for sending messages?

**Answer:** 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?

**Answer:** 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?

**Answer:** 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?

**Answer:** 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.

## Search terms

whatsapp cloud api send template message curl, whatsapp template message json example, graph api whatsapp messages endpoint, whatsapp template parameters body, send whatsapp message from erp, whatsapp api curl example

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
