Send templates
Send templates with named parameters
By default, template parameters are positional — the first
{ type: "text" } fills {{1}}, the second fills {{2}}, and so on.
Templates approved on Meta v18+ can use named parameters instead,
which are more robust to template edits and easier to audit.
A template body approved with named parameters looks like:
Halo {{customer_name}}, pesanan {{order_id}} sudah dikirim.You then send it with parameter_name fields:
curl -X POST \ https://api.kirimdev.com/v1/$PHONE_ID/messages \ -H "Authorization: Bearer $KIRIM_KEY" \ -H "Content-Type: application/json" \ -d '{ "messaging_product": "whatsapp", "to": "+628123456789", "type": "template", "template": { "name": "order_shipped_v2", "language": "id", "components": [ { "type": "body", "parameters": [ { "type": "text", "parameter_name": "customer_name", "text": "Andi" }, { "type": "text", "parameter_name": "order_id", "text": "INV-4521" } ] } ] } }'import { Kirim } from '@kirimdev/sdk'
const kirim = new Kirim({ apiKey: process.env.KIRIM_KEY! })const phone = kirim.phoneNumbers(process.env.PHONE_ID!)
await phone.messages.send({ messaging_product: 'whatsapp', to: '+628123456789', type: 'template', template: { name: 'order_shipped_v2', language: 'id', components: [ { type: 'body', parameters: [ { type: 'text', parameter_name: 'customer_name', text: 'Andi' }, { type: 'text', parameter_name: 'order_id', text: 'INV-4521' }, ], }, ], },})When to use named over positional
Section titled “When to use named over positional”| Reason | Detail |
|---|---|
| Resilient to re-ordering | If you swap {{1}} and {{2}} during template re-approval, named params still resolve correctly |
| Self-documenting code | Reading the request body, you see what each value means without referring back to the template body |
| Required by Meta v18+ for utility templates | Some newer template categories only accept named parameters |
Mixing positional and named
Section titled “Mixing positional and named”You cannot mix the two styles within the same template — Meta picks
the style at approval time. Inspect a template via
GET /v1/{phone_number_id}/templates/{name} to see whether its
parameters are positional or named.