We are making changes to the WhatsApp Business Platform pricing model. See Pricing Updates on the WhatsApp Business Platform.

Sending Media Card Carousel Templates

This document describes how to send approved media card carousel templates to WhatsApp users.

Request Syntax

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

Post Body

{
  "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. */

    ]
  }
}

Post Body Parameters

PlaceholderDescriptionExample Value

<BUTTON_INDEX>

Integer

Required.

Zero-indexed order in which button appears at the bottom of the template message. 0 indicates the first button, 1 indicates second button, etc.

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 0) and a URL button that supports a single variable second (which equates to index 1), if you attempt to send the template with the URL button index set to 0 , the API would return an error ("Parameter value for URL was expected but was not found") because it's expecting a button object with an index of 1 to be present in the post body payload.

0

<CARD_BODY_VARIABLE>

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 text, currency, and date_time types. See Messages Parameters.

There is no maximum character limit on this value, but does count against the card body text limit of 160 characters.

{
  "type":"text",
  "text": "Pablo"
}

<CARD_INDEX>

Integer

Required.

Zero-indexed order in which card should appear within the card carousel. 0 indicates first card, 1 indicates second card, etc.

0

<MESSAGE_BODY_TEXT_VARIABLE>

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 text, currency, and date_time types. See Messages Parameters.

There is no maximum character limit on this value, but it does count against the message body text limit of 1024 characters.

{
  "type":"text",
  "text": "Pablo"
}

<MESSAGE_HEADER_ASSET_ID>

String

Required.

Header asset's uploaded media asset ID. Use the POST /<BUSINESS_PHONE_NUMBER_ID>/media endpoint to generate an asset ID.

1558081531584829

<MESSAGE_HEADER_FORMAT>

String

Required.

Indicates header type and a matching property name.

Note that the <MESSAGE_HEADER_FORMAT> placeholder appears twice in the post body example above, as it serves as a placeholder for the type property's value and its matching property name.

Value can be image or video.

image

<QUICK_REPLY_BUTTON_PAYLOAD>

String

Optional.

Value to be included in messages webhooks (messages.button.payload) when the button is tapped.

more-aloes

<TEMPLATE_LANGUAGE>

String

Required.

Template language and locale code.

en_US

<TEMPLATE_NAME>

String

Required.

Template name.

Maximum 512 characters.

carousel_template_media_cards_v1

<URL_BUTTON_URL_VARIABLE>

String

Required if the URL button URL uses a variable.

URL button variable value.

blue-elf

<WHATSAPP_USER_PHONE_NUMBER>

String

Required.

WhatsApp user phone number.

+16505551234

Example Request

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"
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}'