We are making changes to the WhatsApp Business Platform pricing model. See Pricing Updates on the WhatsApp Business Platform.
This document describes how to send approved media card carousel templates to WhatsApp users.
Use the POST /<WHATSAPP_BUSINESS_PHONE_NUMBER_ID>/messages endpoint to send an approved media card carousel template to a WhatsApp user.
POST /<WHATSAPP_BUSINESS_PHONE_NUMBER_ID>/messages
{ "messaging_product": "whatsapp", "recipient_type": "individual", "to": "<WHATSAPP_USER_PHONE_NUMBER>", "type": "template", "template": { "name": "<TEMPLATE_NAME>", "language": { "code": "<TEMPLATE_LANGUAGE>" }, "components": [ /* Omit if template body text does not use variables */ { "type": "body", "parameters": [ <MESSAGE_BODY_TEXT_VARIABLE>, <MESSAGE_BODY_TEXT_VARIABLE> ] }, { "type": "carousel", "cards": [ { "card_index": <CARD_INDEX>, "components": [ { "type": "header", "parameters": [ { "type": "<MESSAGE_HEADER_FORMAT>", "<MESSAGE_HEADER_FORMAT>": { "id": "<MESSAGE_HEADER_ASSET_ID>" } } ] }, /* Omit if template card body text does not use variables */ { "type": "body", "parameters": [ <CARD_BODY_VARIABLE>, <CARD_BODY_VARIABLE> ] }, /* Omit if template does not use a quick-reply button */ { "type": "button", "sub_type": "quick_reply", "index": <BUTTON_INDEX>, "parameters": [ { "type": "payload", "payload": "<QUICK_REPLY_BUTTON_PAYLOAD>" } ] }, /* Omit if template does not use a URL button */ { "type": "button", "sub_type": "url", "index": <BUTTON_INDEX>, "parameters": [ { "type": "text", "text": "<URL_BUTTON_URL_VARIABLE>" } ] } ] } ] } /* Addt'l cards would follow. All cards must have same components. Must include a card for every card defined on the template. */ ] } }
Placeholder | Description | Example Value |
---|---|---|
Integer | Required. Zero-indexed order in which button appears at the bottom of the template message. Note that if any buttons use variables, the type and order of buttons must match the type and order defined on the template, so you can't use the index values to arrange the order of the buttons in the sent template. For example, if the template defines a phone number button first (which equates to index |
|
Object | Required if the template card body text uses variables, otherwise omit. Object describing a card body variable. If the template uses multiple variables, you must define an object for each variable. Supports There is no maximum character limit on this value, but does count against the card body text limit of 160 characters. |
|
Integer | Required. Zero-indexed order in which card should appear within the card carousel. |
|
Object | Required if template message body text uses variables, otherwise omit. Object describing a message variable. If the template uses multiple variables, you must define an object for each variable. Supports There is no maximum character limit on this value, but it does count against the message body text limit of 1024 characters. |
|
String | Required. Header asset's uploaded media asset ID. Use the POST /<BUSINESS_PHONE_NUMBER_ID>/media endpoint to generate an asset ID. |
|
String | Required. Indicates header type and a matching property name. Note that the Value can be |
|
String | Optional. Value to be included in messages webhooks ( |
|
String | Required. Template language and locale code. |
|
String | Required. Template name. Maximum 512 characters. |
|
String | Required if the URL button URL uses a variable. URL button variable value. |
|
String | Required. WhatsApp user phone number. |
|
This example request sends a media card carousel template named "carousel_template_media_cards_v1". It supplies three body text variables (which the template requires) and contents for three cards (which the template also requires). For each card, the request supplies an image asset ID, a quick-reply button payload (to be included in webhooks when the button is tapped), and a text string to be injected into the URL mapped to the card's URL button (which is defined on the template).
curl 'https://graph.facebook.com/v21.0
/106540352242922/messages' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "+16505551234",
"type": "template",
"template": {
"name": "carousel_template_media_cards_v1",
"language": {
"code": "en_US"
},
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "Pablo"
},
{
"type": "text",
"text": "20%"
},
{
"type": "text",
"text": "20OFF"
}
]
},
{
"type": "carousel",
"cards": [
{
"card_index": 0,
"components": [
{
"type": "header",
"parameters": [
{
"type": "image",
"image": {
"id": "1558081531584829"
}
}
]
},
{
"type": "button",
"sub_type": "quick_reply",
"index": "0",
"parameters": [
{
"type": "payload",
"payload": "more-aloes"
}
]
},
{
"type": "button",
"sub_type": "url",
"index": "1",
"parameters": [
{
"type": "text",
"text": "blue-elf"
}
]
}
]
},
{
"card_index": 1,
"components": [
{
"type": "header",
"parameters": [
{
"type": "image",
"image": {
"id": "861236878885705"
}
}
]
},
{
"type": "button",
"sub_type": "quick_reply",
"index": "0",
"parameters": [
{
"type": "payload",
"payload": "more-crassulas"
}
]
},
{
"type": "button",
"sub_type": "url",
"index": "1",
"parameters": [
{
"type": "text",
"text": "buddhas-temple"
}
]
}
]
},
{
"card_index": 2,
"components": [
{
"type": "header",
"parameters": [
{
"type": "image",
"image": {
"id": "1587064918516321"
}
}
]
},
{
"type": "button",
"sub_type": "quick_reply",
"index": "0",
"parameters": [
{
"type": "payload",
"payload": "more-echeverias"
}
]
},
{
"type": "button",
"sub_type": "url",
"index": "1",
"parameters": [
{
"type": "text",
"text": "black-prince"
}
]
}
]
}
]
}
]
}
}'