Envío de multimedia
A continuación, se mostrarán algunos ejemplos de la configuración de los distintos tipos de envío que llevan multimedia (image, documents, video, audio) dentro de sus mensajes de WhatsApp, cuyo mensaje irá insertado por medio de una URL, importante que a la hora de definir el tipo de multimedia a usar dentro del mensaje se deberá realizar el cambio del valor que tiene el parámetro “type” según la descripción del objeto.
La autenticación de los request se realizará de la misma manera que se realiza para templates por medio de una ApiKey y UserId que serán enviados en los headers de la petición.
Endpoint: v1/apikey/imagebyurl/bsp/send
● Content-Type: application/json
● JSON petición:
Ejemplo imagen
Endpoint: v1/apikey/imagebyurl/bsp/send
{
"from": "{{Origin-WA-ID}}",
"to": "{{Recipient-WA-ID}}",
"type": "image",
"recipient_type": "individual",
"image": {
"provider": {
"name": "<Provider Name from Media Provider API, optional"
},
"link": "<Link to Image, https>",
"caption": "<Media Caption>"
}
}
Ejemplo audio
{
"from": "{{Origin-WA-ID}}",
"to": "{{Recipient-WA-ID}}",
"type": "audio",
"recipient_type": "individual",
"audio": {
"provider": {
"name": "<Provider Name from Media Provider API, optional"
},
"link": "<Link to Audio, https>"
}
}
Ejemplo video
Endpoint: v1/apikey/videobyurl/bsp/send
{
"from": "{{Origin-WA-ID}}",
"to": "{{Recipient-WA-ID}}",
"type": "video",
"recipient_type": "individual",
"video": {
"provider": {
"name": "<Provider Name from Media Provider API, optional"
},
"caption": "<Message Caption>",
"link": "<Link to Video, https>"
}
}
Ejemplo documento
Endpoint: v1/apikey/docbyurl/bsp/send
{
"from": "{{Origin-WA-ID}}",
"to": "{{Recipient-WA-ID}}",
"type": "document",
"recipient_type": "individual",
"document": {
"provider": {
"name": "<Provider Name from Media Provider API, optional"
},
"caption": "<Message Caption>",
"link": "<Link to PDF, https>",
"filename": "<Filename>"
}
}
Ejemplo tipo documento
Endpoint: v1/apikey/stickerbyurl/bsp/send
{
"from": "{{Origin-WA-ID}}",
"to": "{{Recipient-WA-ID}}",
"type": "sticker",
"recipient_type": "individual",
"document": {
"provider": {
"name": "<Provider Name from Media Provider API, optional"
},
"link": "<Link to PDF, https>"
}
}
Ejemplo botones
Endpoint: v1/apikey/interactive/bsp/send
{
"from": "{{Origin-WA-ID}}",
"to": "{{Recipient-WA-ID}}",
"recipient_type": "individual",
"type": "interactive",
"interactive": {
"type": "button",
"header": {
"type": "text",
"text": "Titulo"
},
"body": {
"text": "Body Text"
},
"footer": {
"text": "Footer Text"
},
"action": {
"buttons": [
{
"type": "reply",
"reply": {
"id": "btn1",
"title": "Button 1"
}
},
{
"type": "reply",
"reply": {
"id": "btn2",
"title": "Button 2"
}
},
{
"type": "reply",
"reply": {
"id": "btn3",
"title": "Button 3"
}
}
]
}
}
}
Ejemplo listas
Endpoint: v1/apikey/interactive/bsp/send
{
"from": "{{Origin-WA-ID}}",
"to": "{{Recipient-WA-ID}}",
"recipient_type": "individual",
"type": "interactive",
"interactive": {
"type": "list",
"header": {
"type": "text",
"text": "Titulo"
},
"body": {
"text": "Body Text"
},
"footer": {
"text": "Footer Text"
},
"action": {
"button": "Send",
"sections": [
{
"title": "<Section 1>",
"rows": [
{
"id": "<ID 1.1>",
"title": "<Title 1.1>",
"description": "<Description 1.1>"
},
{
"id": "<ID 1.2>",
"title": "<Title 1.2>",
"description": "<Description 1.2>"
}
]
},
{
"title": "Section 2>",
"rows": [
{
"id": "<ID 2.1>",
"title": "<Title 2.1>",
"description": "<Description 2.1>"
},
{
"id": "<ID 2.2>",
"title": "<Title 2.2>",
"description": "<Description 2.2>"
}
]
}
]
}
}
}
Ejemplo Producto
Endpoint: v1/apikey/interactive/bsp/send
{
"from": "{{Origin-WA-ID}}",
"to": "{{Recipient-WA-ID}}",
"recipient_type": "individual",
"type": "interactive",
"interactive": {
"type": "product",
"body": {
"text": "Body Text"
},
"footer": {
"text": "Footer Text"
},
"action": {
"catalog_id": "Catalog id",
"product_retailer_id": "Product id"
}
}
}
Ejemplo Lista de productos
Endpoint: v1/apikey/interactive/bsp/send
{
"from": "{{Origin-WA-ID}}",
"to": "{{Recipient-WA-ID}}",
"recipient_type": "individual",
"type": "interactive",
"interactive": {
"type": "product_list",
"header": {
"type": "text",
"text": "Titulo"
},
"body": {
"text": "Body Text"
},
"footer": {
"text": "Footer Text"
},
"action": {
"catalog_id": "Catalog id",
"sections": [
{
"title": "the-section-title",
"product_items": [
{
"product_retailer_id": "Product Id"
},
{
"product_retailer_id": "Product Id"
}
],
"product_items": [
{
"product_retailer_id": "Product Id"
},
{
"product_retailer_id": "Product Id"
}
]
}
]
}
}
}
Ejemplo Ubicacion
Endpoint: v1/apikey/location/bsp/send
{
"from": "{{Origin-WA-ID}}",
"to": "{{Recipient-WA-ID}}",
"type": "location",
"location": {
"longitude": -74.052984 (Longitud de la ubicación),
"latitude": 4.69212 (Latitud de la ubicación),
"name": "Nombre de la ubicación",
"address": "Dirección de la ubicación. Solo se muestra si name está presente"
}
}
Ejemplo Contacto o contactos
Endpoint: v1/apikey/contacts/bsp/send
{
"from": "{{Origin-WA-ID}}",
"to": "{{Recipient-WA-ID}}",
"type": "contacts",
"contacts": [
{
"addresses": [
{
"street": "Número y nombre de la calle",
"city": "Nombre de la ciudad",
"state": "Abreviatura de estado",
"zip": "Código postal",
"country": "Nombre completo del país",
"country_code": "Abreviatura de país de dos letras",
"type": "WORK"
}
],
"birthday": "AAAA-MM-DD",
"emails": [
{
"email": "work@test.com",
"type": "WORK"
"email": "home@home.com",
"type": "HOME"
}
],
"name": {
"formatted_name": "Nombre completo, como aparece normalmente.",
"first_name": "Primer nombre",
"last_name": "Apellido",
"middle_name": "Segundo nombre",
"suffix": "Sufijo del nombre",
"prefix": "prefijo del nombre"
},
"org": {
"company": "Nombre de la empresa del contacto",
"department": "Nombre del departamento del contacto",
"title": "Título comercial del contacto"
},
"phones": [
{
"phone": "57320564****",
"type": "HOME"
},
{
"phone": "57319487****",
"type": "WORK",
"wa_id": "Identificación de WhatsApp"
}
],
"urls": [
{
"url": "https://work.com/es/index.html",
"type": "WORK"
},
{
"url": "https://www.home.com",
"type": "HOME"
}
]
},
{
"addresses": [
{
"street": "Número y nombre de la calle",
"city": "Nombre de la ciudad",
"state": "Abreviatura de estado",
"zip": "Código postal",
"country": "Nombre completo del país",
"country_code": "Abreviatura de país de dos letras",
"type": "WORK"
}
],
"birthday": "AAAA-MM-DD",
"emails": [
{
"email": "work@work.com",
"type": "WORK"
},
{
"email": "secondContact@home.com",
"type": "HOME"
}
],
"name": {
"formatted_name": "Nombre completo, como aparece normalmente.",
"first_name": "Primer nombre",
"last_name": "Apellido",
"middle_name": "Segundo nombre",
"suffix": "Sufijo del nombre",
"prefix": "prefijo del nombre"
},
"org": {
"company": "Nombre de la empresa del contacto",
"department": "Nombre del departamento del contacto",
"title": "Título comercial del contacto"
},
"phones": [
{
"phone": "5735056*****",
"type": "HOME"
},
{
"phone": "5732148*****",
"type": "WORK",
"wa_id": "Identificación de WhatsApp"
}
],
"urls": [
{
"url": "https://work.com/es/index.html",
"type": "WORK"
},
{
"url": "https://www.home.com",
"type": "HOME"
}
]
}
]
}
Ejemplo Interactiva encabezado video
Endpoint: v1/apikey/interactive/bsp/send
{
"from": "{{Origin-WA-ID}}",
"to": "{{Recipient-WA-ID}}",
"type": "interactive",
"recipient_type": "individual",
"interactive": {
"type": "button",
"header": {
"type": "video",
"video": {
"link": "<Link to Video, https>"
}
},
"body": {
"text": "contenido"
},
"footer": {
"text": "pie de página"
},
"action": {
"buttons": [
{
"type": "reply",
"reply": {
"id": "btn1",
"title": "primer botón"
}
},
{
"type": "reply",
"reply": {
"id": "btn2",
"title": "segundo botón"
}
}
]
}
}
}
Esta funcionalidad es solo para mensajes interactivos en donde el tipo es button.
Ejemplo Interactiva encabezado imagen
Endpoint: v1/apikey/interactive/bsp/send
{
"from": "{{Origin-WA-ID}}",
"to": "{{Recipient-WA-ID}}",
"type": "interactive",
"recipient_type": "individual",
"interactive": {
"type": "button",
"header": {
"type": "image",
"video": {
"link": "<Link to Image, https>"
}
},
"body": {
"text": "contenido"
},
"footer": {
"text": "pie de página"
},
"action": {
"buttons": [
{
"type": "reply",
"reply": {
"id": "btn1",
"title": "primer botón"
}
},
{
"type": "reply",
"reply": {
"id": "btn2",
"title": "segundo botón"
}
}
]
}
}
}
Esta funcionalidad es solo para mensajes interactivos en donde el tipo es button
Ejemplo Interactiva encabezado documento
Endpoint: v1/apikey/interactive/bsp/send
{
"from": "{{Origin-WA-ID}}",
"to": "{{Recipient-WA-ID}}",
"type": "interactive",
"recipient_type": "individual",
"interactive": {
"type": "button",
"header": {
"type": "document",
"video": {
"link": "<Link to Document, https>",
"filename": "name file optional",
}
},
"body": {
"text": "contenido"
},
"footer": {
"text": "pie de página"
},
"action": {
"buttons": [
{
"type": "reply",
"reply": {
"id": "btn1",
"title": "primer botón"
}
},
{
"type": "reply",
"reply": {
"id": "btn2",
"title": "segundo botón"
}
}
]
}
}
}
Esta funcionalidad es solo para mensajes interactivos en donde el tipo es button.
Parámetros:
Nombre | Descripción |
---|---|
from | Obligatorio. Campo que contiene el número de origen. |
to | Obligatorio. Campo que contiene el número de destino. |
type | Obligatorio. El tipo de mensaje que desea enviar. Valores admitidos: ● Image - Utilizado para imágenes. ● Audio - Utilizado para audios. ● Video - Utilizado para videos. ● Document - Utilizado para documentos. ● Sticker - Utilizado para stickers |
recipient_type | Opcional. El tipo de destinatario al que se envía el mensaje. Valor admitido: individual |
image | Necesario para los mensajes de image type. Contiene un image object. |
audio | Necesario para los mensajes de audio type. Contiene un audio object. |
video | Necesario para los mensajes de video type. Contiene un video object. |
document | Necesario para los mensajes de document type. Contiene un document object. |
interactive | Necesario para los mensajes de interactive type. Contiene un interactive object. |
location | Necesario para los mensajes de location type. Contiene un location object. |
contacts | Necesario para los mensajes de contacts type. Contiene un contacts object. |
Descripción de la respuesta:
En caso de todo estar todo correcto, el servicio responde:
{
"messages": [
{
"id": "gBEGkYiEB1VXAglK1ZEqA1YKPrU"
}
]
}
En caso de estar mal algún dato de autenticación (ApiKey : API_KEY) ,el servicio responde 401:
{
"errors": [
"Authentication Error"
]
}
En caso de faltar algún dato del request el servicio responde 400:
{
"errors": [
"Bad Request"
]
}