WhatsApp API Usage Guide
This guide provides practical examples of using the Meta WhatsApp Business API with our service.
Table of Contents
Introduction
The WhatsApp Business API allows you to send template messages to your customers. Template messages are pre-approved message formats that can include text, media, and interactive components such as buttons.
To use this service, you'll need:
- A valid WhatsApp Business Account (WABA)
- Approved message templates
- Valid phone numbers registered with WhatsApp
- An API key from LlamadaPro
Template Messages
Template messages must follow Meta's approved format. These examples show how to construct valid template messages using our API.
Simple Text Template
A basic template with text variables in the body:
curl -X POST https://api.llamadapro.app/api/v1/messaging/whatsapp/messages/templates \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"fromPhoneNumber": "+1234567890",
"toPhoneNumber": "+0987654321",
"templateName": "welcome_message",
"languageCode": "en",
"variables": [
{ "value": "John" },
{ "value": "Doe" }
]
}'
Templates with Media
A template with an image in the header:
curl -X POST https://api.llamadapro.app/api/v1/messaging/whatsapp/messages/templates \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"fromPhoneNumber": "+1234567890",
"toPhoneNumber": "+0987654321",
"templateName": "product_update",
"languageCode": "en",
"components": [
{
"type": "header",
"parameters": [
{
"type": "image",
"image": {
"link": "https://example.com/product-image.jpg"
}
}
]
},
{
"type": "body",
"parameters": [
{ "type": "text", "text": "New Product" },
{ "type": "text", "text": "$99.99" }
]
}
]
}'
Templates with Buttons
Quick Reply Buttons
Quick reply buttons allow users to respond with predefined options:
curl -X POST https://api.llamadapro.app/api/v1/messaging/whatsapp/messages/templates \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"fromPhoneNumber": "+1234567890",
"toPhoneNumber": "+0987654321",
"templateName": "feedback_request",
"languageCode": "en",
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "John" }
]
},
{
"type": "button",
"subType": "quick_reply",
"index": "0",
"parameters": [
{
"type": "payload",
"payload": "FEEDBACK_YES"
}
]
},
{
"type": "button",
"subType": "quick_reply",
"index": "1",
"parameters": [
{
"type": "payload",
"payload": "FEEDBACK_NO"
}
]
}
]
}'
URL Buttons
URL buttons direct users to a website with a dynamic URL suffix:
curl -X POST https://api.llamadapro.app/api/v1/messaging/whatsapp/messages/templates \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"fromPhoneNumber": "+1234567890",
"toPhoneNumber": "+0987654321",
"templateName": "appointment_confirmation",
"languageCode": "en",
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "Dr. Smith" },
{ "type": "text", "text": "July 21, 2023" },
{ "type": "text", "text": "10:30 AM" }
]
},
{
"type": "button",
"subType": "url",
"index": "0",
"parameters": [
{
"type": "text", // Note: URL buttons use "text" type, not "payload"
"text": "abc123", // Dynamic URL suffix that will be appended to base URL defined in template
}
]
}
]
}'
Phone Number Buttons
Button that initiates a phone call:
curl -X POST https://api.llamadapro.app/api/v1/messaging/whatsapp/messages/templates \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"fromPhoneNumber": "+1234567890",
"toPhoneNumber": "+0987654321",
"templateName": "support_contact",
"languageCode": "en",
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "Customer Support" }
]
},
{
"type": "button",
"subType": "phone_number",
"index": "0",
"parameters": [
{
"type": "text",
"text": "+18001234567"
}
]
}
]
}'