WhatsApp Templates
WhatsApp requires all business messages to use pre-approved templates. This endpoint allows you to fetch all approved templates for a specific phone number.
Fetch Templates
Retrieve all WhatsApp templates associated with a specific phone number.
Endpoint
GET /v1/phone_number_ids/{id}/templates
Path Parameters
Parameter | Type | Required | Description |
---|---|---|---|
id | integer | Yes | The id from the phone numbers endpoint. Use id and not phone_number_id which is also present in the endpoint |
Request
curl -X GET "https://whatsapp.smsleopard.com/v1/phone_number_ids/1/templates" \
-H "Authorization: Basic <your_credentials>" \
-H "Content-Type: application/json"
Response
[
{
"id": "1250589476699956",
"account_id": 0,
"button": [
{
"phone_number": "",
"text": "Copy code",
"type": "URL",
"url": "https://www.whatsapp.com/otp/code/?otp_type=COPY_CODE&code_expiration_minutes=5&code=otp{{1}}"
}
],
"footer": "This code expires in 5 minutes.",
"header": null,
"language": "en_US",
"message": "*{{1}}* is your verification code. For your security, do not share this code.",
"name": "authentication",
"status": "APPROVED",
"type": "AUTHENTICATION"
}
]
Template Fields
Field | Type | Description |
---|---|---|
id | string | Unique template ID (use this when sending messages) |
account_id | integer | WhatsApp Business Account ID |
button | array | Interactive buttons (if any) |
footer | string | Footer text (optional) |
header | object | Header content (optional) |
language | string | Template language code |
message | string | Main message body with placeholders |
name | string | Template name identifier |
status | string | Approval status (APPROVED , PENDING , REJECTED ) |
type | string | Template category |
Template Management Tips
- Only use APPROVED templates - Templates with other statuses cannot be used for messaging
- Check template variables - Ensure you have values for all placeholders
Error Response Shape
The API returns a consistent error response shape for all errors:
{
"error_code": string, // e.g., "bad_request", "invalid_format", "unauthorized"
"error_message": string, // actual error message describing the issue
"status_code": integer // e.g., 400, 401, 404, 500
}
Next Steps
With your templates ready: