Media and location
Integration summary
- Endpoint:
POST https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging- Token: messaging token, in the
Authorization: Bearer {{wa-msg-api-token}}header (how to generate it)- Common fields:
from,to(phone number or BSUID) andtype(details)typevalues on this page:"template"- Response: the same for every message (see response)
Image, document, video and location parameters for the header component of the template. All are sent with POST /v1/messaging; headers, common fields and the response are in HTTP connection. The general template structure (template and components objects) is in Template messages.
Note: exactly one media parameter must be sent in the header component.
Image
Image parameter for the header component. In the parameter object, type must be "image".
Body
Fields for Image:
| Name | Description | Type | Requirements |
|---|---|---|---|
| type | The value is "image". | String | Required |
| link | Image URL. | String | link or media_id required (one of them). |
| media_id | WhatsApp media resource ID. | String | link or media_id required (one of them). |
Example
Complete Image example (HTTP request and JSON body):
Image HTTP request
curl -X POST 'https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "bienvenida","components": [{"type": "header","parameters": [{"link": "https://www.ejemplo.com/ejemplo.jpg","type": "image"}]},{"type": "body","parameters": [{"text": "sample text","type": "text"}]}]}}'
Image body
{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "bienvenida","components": [{"type": "header","parameters": [{"link": "https://www.ejemplo.com/ejemplo.jpg","type": "image"}]},{"type": "body","parameters": [{"text": "sample text","type": "text"}]}]}}
Document
Document parameter for the header component. In the parameter object, type must be "document".
Body
Fields for Document:
| Name | Description | Type | Requirements |
|---|---|---|---|
| type | The value is "document". | String | Required |
| link | Document URL. | String | link or media_id required (one of them). |
| media_id | WhatsApp media resource ID. | String | link or media_id required (one of them). |
| filename | Document file name. | String | Optional |
Example
Complete Document example (HTTP request and JSON body):
Document HTTP request
curl -X POST 'https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "bienvenida","components": [{"type": "header","parameters": [{"link": "http://victormoran.me/leo/Broadcaster-RCS_API_v1.0.pdf","type": "document","filename": "RCS Documentation"}]},{"type": "body","parameters": [{"text": "sample text","type": "text"}]}]}}'
Document body
{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "bienvenida","components": [{"type": "header","parameters": [{"link": "http://victormoran.me/leo/Broadcaster-RCS_API_v1.0.pdf","type": "document","filename": "RCS Documentation"}]},{"type": "body","parameters": [{"text": "sample text","type": "text"}]}]}}
Video
Video parameter for the header component. In the parameter object, type must be "video".
Body
Fields for Video:
| Name | Description | Type | Requirements |
|---|---|---|---|
| type | The value is "video". | String | Required |
| link | Video URL. | String | link or media_id required (one of them). |
| media_id | WhatsApp media resource ID. | String | link or media_id required (one of them). |
Example
Complete Video example (HTTP request and JSON body):
Video HTTP request
curl -X POST 'https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "bienvenida","components": [{"type": "header","parameters": [{"link": "https://victormoran.me/leo/PruebasWhatsApp/video_3.7_MB.mp4","type": "video","filename": "video"}]},{"type": "body","parameters": [{"text": "sample text","type": "text"}]}]}}'
Video body
{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "bienvenida","components": [{"type": "header","parameters": [{"link": "https://victormoran.me/leo/PruebasWhatsApp/video_3.7_MB.mp4","type": "video","filename": "video"}]},{"type": "body","parameters": [{"text": "sample text","type": "text"}]}]}}
GIF
GIF parameter for the header component. In the parameter object, type must be "gif". The template must have been created with a GIF header.
Note: GIFs are MP4 files (the
linkmust point to an MP4), with a maximum size of 3.5 MB. GIF headers are only available for MARKETING templates sent from WABAs with Marketing Messages Lite (MM Lite) enabled; in any other case WhatsApp displays the file as a video message. Unlike the other media types, the GIF parameter only acceptslink(notmedia_id).
Body
Fields for GIF:
| Name | Description | Type | Requirements |
|---|---|---|---|
| type | The value is "gif". | String | Required |
| link | URL of the MP4 file. Maximum 3.5 MB. | String | Required |
Example
Complete GIF example (HTTP request and JSON body):
GIF HTTP request
curl -X POST 'https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "bienvenida","components": [{"type": "header","parameters": [{"type": "gif","link": "https://www.ejemplo.com/ejemplo.mp4"}]},{"type": "body","parameters": [{"text": "sample text","type": "text"}]}]}}'
GIF body
{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "bienvenida","components": [{"type": "header","parameters": [{"type": "gif","link": "https://www.ejemplo.com/ejemplo.mp4"}]},{"type": "body","parameters": [{"text": "sample text","type": "text"}]}]}}
Location
Location parameter for the header component. In the parameter object, type must be "location".
Body
Fields for Location:
| Name | Description | Type | Requirements |
|---|---|---|---|
| type | The value is "location". | String | Required |
| location | Object with the location. | Object | Required |
Fields of the location object:
| Name | Description | Type | Requirements |
|---|---|---|---|
| longitude | Longitude. | Number | Required |
| latitude | Latitude. | Number | Required |
| name | Location name. | String | Required |
| address | Location address. | String | Required |
Example
Complete Location example (HTTP request and JSON body):
Location HTTP request
curl -X POST 'https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "bienvenida","components": [{"type": "header","parameters": [{"type": "location","location": {"longitude": -99.1841566,"latitude": 19.4260393,"name": "Concepto Móvil","address": "Shakespeare 39, Floor 3, Anzures, Miguel Hidalgo, 11590 Mexico City, CDMX"}}]},{"type": "body","parameters": [{"text": "sample text","type": "text"}]}]}}'
Location body
{"from": "5215500000001","to": "5215500000002","type": "template","template": {"language": "es","name": "bienvenida","components": [{"type": "header","parameters": [{"type": "location","location": {"longitude": -99.1841566,"latitude": 19.4260393,"name": "Concepto Móvil","address": "Shakespeare 39, Floor 3, Anzures, Miguel Hidalgo, 11590 Mexico City, CDMX"}}]},{"type": "body","parameters": [{"text": "sample text","type": "text"}]}]}}
