Media templates must be pre-approved by Facebook. You can submit your template for approval using 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.
Considering the following media template is approved by Facebook.
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"}'
The HTTP response should be 202 Accepted and it should contain the message ID.
{"id": "4a968dd619f54d9582440d15aaa791ec"}
Considering the following media template is approved by Facebook.
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 $'{"to": "31612345678","channelId": "2181d3bb46f5449aad0309f852b36ba5","type": "hsm","content": {"hsm": {"namespace": "20132cc4_f094_b090_d255_35677159bbdt","templateName": "test_media_template_with_video_header","language": {"policy": "deterministic","code": "en"},"components": [{"type": "header","parameters": [{"video": {"url": "https://www.yourcompany.com/videos/sample.mp4"},"type": "video"}]},{"type": "body","parameters": [{"type": "text","text": "Robert"}]}]}}}'
The HTTP response should be 202 Accepted and it should contain the message ID.
{"id": "4a968dd619f54d9582440d15aaa791ec"}
Considering the following media template is approved by Facebook.
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 $'{"to": "31612345678","channelId": "2181d3bb46f5449aad0309f852b36ba5","type": "hsm","content": {"hsm": {"namespace": "20132cc4_f094_b090_d255_35677159bbdt","templateName": "test_media_template_with_document_header","language": {"policy": "deterministic","code": "en"},"components": [{"type": "header","parameters": [{"document": {"url": "https://www.yourcompany.com/documents/contract.pdf"},"type": "document"}]},{"type": "body","parameters": [{"type": "text","text": "Robert"}]}]}}}'
The HTTP response should be 202 Accepted and it should contain the message ID.
{"id": "4a968dd619f54d9582440d15aaa791ec"}