Interactive & media
WhatsApp templates can include interactive buttons and attach media such as images, documents, audio, and video. Buttons are defined on the template's WhatsApp variant; media is attached per send with media_url and media_type.
POST/messages
Templates with buttons
Buttons are declared on the WhatsApp channel variant of a template. A URL button can point at a value filled from a template variable:
{
"channel": "whatsapp",
"content": "Welcome {{customer_name}}! 🎉\n\nThank you for joining our platform.",
"header": "Welcome!",
"footer": "We're here to help",
"buttons": [
{
"type": "url",
"text": "Get Started",
"variable_name": "website_url"
}
]
}
Once the template is approved, send it like any other WhatsApp message — the buttons render automatically:
curl -X POST https://api.tryzend.com/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+233593152134",
"body": "Your verification code is ready",
"preferred_channels": ["whatsapp"],
"template_id": "12345678912345",
"template_params": {
"customer_name": "John",
"website_url": "https://yourapp.com/start"
}
}'
Button types
URL buttons
Open a link when tapped. The destination comes from a template variable via variable_name:
{
"buttons": [
{
"type": "url",
"text": "Visit Website",
"variable_name": "website_url"
}
]
}
Quick reply buttons
Send a predefined reply back to your business. Quick replies use static text and take no variable:
{
"buttons": [
{
"type": "quick_reply",
"text": "Yes, I'm interested"
},
{
"type": "quick_reply",
"text": "No, thanks"
}
]
}
Note
Limit templates to a maximum of 3 buttons, keep button text within 25 characters, and use clear, action-oriented labels.
Sending media
Attach media to a WhatsApp send with media_url and media_type:
curl -X POST https://api.tryzend.com/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+233593152134",
"body": "Check out our latest product catalog!",
"preferred_channels": ["whatsapp"],
"template_id": "12345678912345",
"template_params": {
"product_name": "Premium Widget",
"price": "$99.99"
},
"media_url": "https://example.com/catalog.pdf",
"media_type": "document"
}'
Request fields
media_urlstring
HTTPS URL of the media file to attach. Files should be under 16MB.
media_typestring
Type of media:
image, document, audio, or video.Supported media types
media_type | Formats |
|---|---|
image | JPG, PNG, GIF |
document | PDF, DOC, XLS |
audio | MP3, OGG |
video | MP4, 3GP |
Related
- Send WhatsApp — overview and basic template send.
- WhatsApp templates — approved templates and variables.
- WhatsApp delivery & fallback — status, webhooks, and errors.