Skip to Content

Templates

Returns all approved WhatsApp message templates linked to a given phone number. Each template includes an expected_variables field that tells you exactly which values to pass when sending.

Create templates in the Bahasha Dashboard  if you haven’t already.

List templates for a phone number

GET /v1/whatsapp/phone_numbers/:phone_number_id/templates

The :phone_number_id is the id field returned by the Phone Numbers endpoint.

The phone_number_id used in all requests is the id field returned by the Phone Numbers endpoint. This is different from the actual phone number itself.

curl https://api.bahasha.app/v1/whatsapp/phone_numbers/123456789/templates \ -H "Authorization: Bearer bh_live_xxxxxxxxxxxx"

Response

[ { "id": "6643c2a1f4e3b12d5c9a0001", "name": "order_confirmation", "language": "en_US", "category": "UTILITY", "status": "APPROVED", "components": [ { "type": "BODY", "text": "Hi {{customer_name}}, your order {{order_id}} is confirmed." } ], "expected_variables": { "header": [], "body": [ { "param_name": "customer_name", "example": "John Doe" }, { "param_name": "order_id", "example": "ORD-12345" } ], "buttons": [] } } ]

Key fields

FieldDescription
idUse this as templateId in all media endpoints.
nameTemplate name — use this as template_name when sending
languageLanguage code — use this as language_code when sending
expected_variablesObject with header, body, and buttons arrays. Each entry has a param_name (key to use when sending) and an example value.

Get a specific template by name

GET /v1/whatsapp/phone_numbers/:phone_number_id/templates/:templateName

Fetches a single template by its name. Use this when you already know the template name and want its expected_variables without fetching the full list. Template names can be found in the Bahasha dashboard.

curl https://api.bahasha.app/v1/whatsapp/phone_numbers/123456789/templates/order_confirmation \ -H "Authorization: Bearer bh_live_xxxxxxxxxxxx"

Response

{ "id": "6643c2a1f4e3b12d5c9a0001", "name": "order_confirmation", "language": "en_US", "category": "UTILITY", "status": "APPROVED", "components": [ { "type": "BODY", "text": "Hi {{customer_name}}, your order {{order_id}} is confirmed." } ], "expected_variables": { "header": [], "body": [ { "param_name": "customer_name", "example": "John Doe" }, { "param_name": "order_id", "example": "ORD-12345" } ], "buttons": [] } }

Returns 404 if the template name does not exist or is not accessible for the given phone number.


Understanding expected_variables

The expected_variables object tells you what to pass in the variables field when sending. There are three variable styles:

Styleparam_name typeExample key in variables
No variablesOmit variables entirely
NamedString, e.g. "customer_name"variables.body.customer_name
PositionalNumber, e.g. 1variables.body["1"]

Authentication templates always have a single body variable with param_name: 1 — this is the OTP code.

See Passing template variables for full examples.