WhatsApp API (Beta)
Templates

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

ParameterTypeRequiredDescription
idintegerYesThe 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

FieldTypeDescription
idstringUnique template ID (use this when sending messages)
account_idintegerWhatsApp Business Account ID
buttonarrayInteractive buttons (if any)
footerstringFooter text (optional)
headerobjectHeader content (optional)
languagestringTemplate language code
messagestringMain message body with placeholders
namestringTemplate name identifier
statusstringApproval status (APPROVED, PENDING, REJECTED)
typestringTemplate category

Template Management Tips

  1. Only use APPROVED templates - Templates with other statuses cannot be used for messaging
  2. 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:

  1. Learn how to send template messages
  2. See practical examples