# WhatsApp error 132000: template param count mismatch

URL: https://wa.genuka.com/en/docs/errors/132000
Language: English

> WhatsApp error 132000 (Template Param Count Mismatch): the variables you sent do not match the template. How to count them and send them correctly.

WhatsApp error 132000 means the number of values you sent for the template's variables does not
match the number of variables the template contains. Meta refuses the message without sending it.
Count the variables of the approved template, header and body, then send exactly one value per
variable, in the right order.

## What does error 132000 mean?

> "The number of variable parameter values included in the request did not match the number of
> variable parameters defined in the template."
> — [Meta, Cloud API error codes](https://developers.facebook.com/documentation/business-messaging/whatsapp/support/error-codes#other-errors)

Meta asks you to make sure the request includes a value for **every** parameter the template
requires. The title that comes with the code in the `message` field is "Template Param Count
Mismatch" ([360dialog's list](https://docs.360dialog.com/docs/support/api-error-message-list)).

A template declares its variables in a format chosen at creation
([Meta, Templates, parameter formats](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/overview)):

| Format               | How it is written in the template            | Rule at send time                                    |
| -------------------- | -------------------------------------------- | ---------------------------------------------------- |
| Positional (default) | `{{1}}`, `{{2}}`…                            | Values follow the order of the variables in the text |
| Named                | `{{first_name}}` (lowercase and underscores) | Values can come in any order                         |

## When does error 132000 happen?

* **A forgotten header variable**: the title "Order `{{1}}` shipped" has its own variable, which
  is not filled by the body's.
* **A template edited after the integration**: a variable was added to the text, the code still
  sends the old number of values.
* **A campaign with uneven variables**: some recipients have two values, others one.
* **An empty or missing array** because a piece of data was missing in your app (unknown first
  name, an order number filtered out as `null`).

### Where do you see it in Genuka WA?

| Channel                          | What you get                                                                                                                        |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `POST /api/v1/messages` response | `400`, `"error": "send_template"`, `meta.code: 132000`, `meta.retryable: false`                                                     |
| Campaign                         | The affected recipients turn `failed`; if the variables have the same shape for everyone, **the whole** campaign fails the same way |

Genuka WA classifies every 132xxx code as `template`: the error is in the request, and sending it
again unchanged will always fail.

## How do I fix error 132000?

1. **Read the template as approved** with `GET /api/v1/templates/{id}`: the `components` field holds
   the header and body text.

2. **Count each component's variables**: the text header's on one side, the body's on the other.

3. **Put each value in the right field** of `template`:

   | In the template                  | In `POST /api/v1/messages`                                |
   | -------------------------------- | --------------------------------------------------------- |
   | Positional body `{{1}}`, `{{2}}` | `body` (or its alias `variables`): an array, in order     |
   | Named body `{{first_name}}`      | `bodyNamed`: an object `{ "first_name": "Awa" }`          |
   | Text header with `{{1}}`         | `header: { "text": "ORD-1042" }`                          |
   | Image, video or document header  | `header: { "image": { "assetId": "ast_1" } }`             |
   | Dynamic URL button               | `buttons: [{ "type": "url", "text": "1042" }]`            |
   | Authentication template          | `otp: "472913"`, which fills both the body and the button |

**curl**

```bash
# 1. The template as approved
curl https://wa.genuka.com/api/v1/templates/tpl_123 \
  -H "Authorization: Bearer $GENUKA_WA_API_KEY"
# "components": [
#   { "type": "HEADER", "format": "TEXT", "text": "Order {{1}} shipped" },
#   { "type": "BODY", "text": "Hi {{1}}, your parcel arrives {{2}}." }
# ]

# 2. One value for the header, two for the body
curl -X POST https://wa.genuka.com/api/v1/messages \
  -H "Authorization: Bearer $GENUKA_WA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "connectionId": "con_1",
    "to": "+237690000001",
    "template": {
      "name": "parcel_shipped",
      "language": "en",
      "header": { "text": "ORD-1042" },
      "body": ["Awa", "tomorrow"]
    }
  }'
```

**Node.js**

```ts
type Component = { type: string; format?: string; text?: string };

const VARIABLE = /\{\{\s*([a-z0-9_]+)\s*\}\}/g;

/** How many values the template expects, per component. */
export function expectedParams(components: Component[]) {
  const count = (type: string) => {
    const component = components.find((c) => c.type.toUpperCase() === type);
    if (!component?.text) return 0;
    if (type === "HEADER" && component.format && component.format.toUpperCase() !== "TEXT") return 0;
    return new Set([...component.text.matchAll(VARIABLE)].map((match) => match[1])).size;
  };
  return { header: count("HEADER"), body: count("BODY") };
}

// Before sending: refuse locally rather than letting Meta answer 132000.
const { data: template } = await fetch("https://wa.genuka.com/api/v1/templates/tpl_123", {
  headers: { Authorization: `Bearer ${process.env.GENUKA_WA_API_KEY}` },
}).then((response) => response.json());

const expected = expectedParams(template.components);
const body = ["Awa", "tomorrow"];
if (body.length !== expected.body) {
  throw new Error(`The body expects ${expected.body} value(s), got ${body.length}`);
}
```

**Python**

```python
import re

VARIABLE = re.compile(r"\{\{\s*([a-z0-9_]+)\s*\}\}")


def expected_params(components: list[dict]) -> dict:
    """How many values the template expects, per component."""

    def count(kind: str) -> int:
        component = next((c for c in components if c.get("type", "").upper() == kind), None)
        if not component or not component.get("text"):
            return 0
        if kind == "HEADER" and component.get("format", "TEXT").upper() != "TEXT":
            return 0
        return len(set(VARIABLE.findall(component["text"])))

    return {"header": count("HEADER"), "body": count("BODY")}
```

## How do I prevent error 132000?

* **Validate before sending**, with a counter like the one above, and refuse an incomplete request
  locally: the error shows up earlier and names the missing data.
* **Version your templates** (`parcel_shipped_v2`) when you change their variables, rather than
  editing a template your code already relies on.
* **Check every campaign recipient** before `POST /api/v1/campaigns`: the same number of values for
  everyone, no empty value.
* **Check the format too**: a template created with named parameters is filled with `bodyNamed`,
  not with an array.

## Related error codes

* [132001](https://wa.genuka.com/en/docs/errors/132001): the template itself cannot be found in that language, or is
  not approved.
* [132015](https://wa.genuka.com/en/docs/errors/132015): the template is paused for low quality.
* [131047](https://wa.genuka.com/en/docs/errors/131047): the 24-hour window is closed, hence the switch to a template.

## FAQ

### Do the examples given at creation count at send time?

No. Examples are there for Meta's review of the template; at send time you provide the real
values, one per variable.

### Does the order of values matter?

For a positional template, yes: the first value fills `{{1}}`, the second `{{2}}`. For a named
template, no: Meta accepts values in any order.

### Why does my whole campaign fail with 132000?

Because the error comes from the shape of the variables, which is the same for every recipient.
Genuka WA does not retry a template error, and a campaign that was already launched only resends
its recipients that are still `pending`: fix the variables, then create a new campaign.

## Sources

* [Meta — Error codes](https://developers.facebook.com/documentation/business-messaging/whatsapp/support/error-codes)
* [Meta — Templates overview, parameter formats](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/overview)
* [360dialog — API error message list](https://docs.360dialog.com/docs/support/api-error-message-list)
