logo
enes

Media and location

Last update: 5 hours ago by Irais Aguirre

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) and type (details)
  • type values 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:

NameDescriptionTypeRequirements
typeThe value is "image".StringRequired
linkImage URL.Stringlink or media_id required (one of them).
media_idWhatsApp media resource ID.Stringlink 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:

NameDescriptionTypeRequirements
typeThe value is "document".StringRequired
linkDocument URL.Stringlink or media_id required (one of them).
media_idWhatsApp media resource ID.Stringlink or media_id required (one of them).
filenameDocument file name.StringOptional

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:

NameDescriptionTypeRequirements
typeThe value is "video".StringRequired
linkVideo URL.Stringlink or media_id required (one of them).
media_idWhatsApp media resource ID.Stringlink 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 link must 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 accepts link (not media_id).

Body

Fields for GIF:

NameDescriptionTypeRequirements
typeThe value is "gif".StringRequired
linkURL of the MP4 file. Maximum 3.5 MB.StringRequired

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:

NameDescriptionTypeRequirements
typeThe value is "location".StringRequired
locationObject with the location.ObjectRequired

Fields of the location object:

NameDescriptionTypeRequirements
longitudeLongitude.NumberRequired
latitudeLatitude.NumberRequired
nameLocation name.StringRequired
addressLocation address.StringRequired

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


Previous
Text, currency and date
Next
Buttons