How to Send a Media Template Message

Media templates must be pre-approved by Facebook. If you have access to Facebook Template Manager, you can submit your template for approval. If you don't have access to the Facebook Template Manager, please send an email message to our Customer Support team (support@messagebird.com), who will ask for the required template data. Once this is received, the Support team will then confirm with you if the template has been approved by Facebook.

Notification icon

Media template submissions are not currently possible through MessageBird's WhatsApp Template Manager.

In order to send a WhatsApp media template message, you must use one of the Conversations API endpoints for sending messages (see bellow). The message type must be hsm and the content.hsm must be set. Currently, the only supported media types are document and image.

Considering the following media template is approved by Facebook.

Media template with buttons

In order to send a WhatsApp message using this template, you must perform the following HTTP request to Conversations API. The following example uses the endpoint POST /v1/send, however, you can also use the other endpoints for sending messages, please check the Conversations API reference for details about the request.

curl -X "POST" "https://conversations.messagebird.com/v1/send" \
-H 'Authorization: AccessKey test_gshuPaZoeEG6ovbc8M79w0QyM' \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{
"content": {
"hsm": {
"language": {
"code": "en"
},
"components": [
{
"type": "header",
"parameters": [
{
"type": "image",
"image": {
"url": "https://www.messagebird.com/images/banner.jpg"
}
}
]
},
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "John"
},
{
"type": "text",
"text": "MB93824"
},
{
"type": "text",
"text": "2 days"
},
{
"type": "text",
"text": "MessageBird"
}
]
}
],
"namespace": "20132cc4_f094_b090_d255_35677159bbdt",
"templateName": "33172012024_ship_img_but_1"
}
},
"to": "+31612345678",
"type": "hsm",
"from": "2181d3bb46f5449aad0309f852b36ba5"
}'
  • content.hsm.namespace can be found in the WhatsApp Templates Manager of your Facebook Business account, or, in case you don't have access to it, please contact our support team
  • content.hsm.language.code is the language which the template message should be sent
  • content.hsm.templateName is the template name
  • content.hsm.components[0].type must be header as the template has an image header
  • content.hsm.components[0].image.url must contain an image URL because the template has an image header
  • content.hsm.components[1].type must be body because the template has variables in the message body
  • content.hsm.components[1].type.parameters must contain a list of objects with the values that should be set in the variables
  • content.hsm.components[1].type.parameters[0..3].type must be text as the variable type is text
  • content.hsm.components[1].type.parameters[0..3].text contains the value of the variable
  • to is the phone number of the recipient
  • type must be hsm because this is a template message
  • from must be your WhatsApp channel ID

The HTTP response should be 202 Accepted and it should contain the message ID.

{
"id": "4a968dd619f54d9582440d15aaa791ec"
}

Questions?

We’re always happy to help with code or other doubts you might have! Check out our Quickstarts, API Reference, Tutorials, SDKs, or contact our Support team.

Cookie Settings