Contenido multimedia
Resumen para integración
- Endpoint:
POST https://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging- Token: de mensajería, en el encabezado
Authorization: Bearer {{wa-msg-api-token}}(cómo generarlo)- Campos comunes:
from,to(teléfono o BSUID) ytype(detalle)- Valores de
typeen esta página:"image","document","video","sticker","audio"- Respuesta: la misma para todos los mensajes (ver respuesta)
Mensajes con un archivo adjunto: imagen, documento, video, sticker, audio o mensaje de voz. Todos se envían con POST /v1/messaging; los encabezados, los campos comunes y la respuesta están en Conexión HTTP.
Contenido multimedia
Envía un archivo por su liga (link) o por su identificador en WhatsApp (media_id). El campo type indica el tipo de archivo: audio, document, image, sticker o video.
Cuerpo
Campos de Contenido multimedia, además de los campos comunes:
| Nombre | Descripción | Tipo | Requerimientos |
|---|---|---|---|
| type | Tipo de contenido. Los valores pueden ser: audio, document, image, sticker y video. | String | Obligatorio. |
| link | Liga del archivo. La URL debe ser pública y el archivo no debe exceder el tamaño máximo permitido para tu número. | String |
|
| media_id | Identificador de un archivo multimedia previamente cargado en WhatsApp. Se usa en lugar de link. | String |
|
| filename | Nombre del archivo. | String |
|
| caption | Descripción del archivo. | String |
|
| voice | Si el valor es true, el audio se envía como mensaje de voz (nota de voz) en lugar de un archivo de audio. | Boolean |
|
Ejemplos
Imagen
Petición HTTP
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": "image","link": "https://www.ejemplo.com/ejemplo_imagen.png","caption": "Este es caption de tipo image"}'
Body
{"from": "5215500000001","to": "5215500000002","type": "image","link": "https://www.ejemplo.com/ejemplo_imagen.png","caption": "Este es caption de tipo image"}
Documento
Petición HTTP
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": "document","link": "https://www.ejemplo.com/ejemplo_documento.pdf","caption":"Este es el caption de tipo document","filename":"ejemplo_documento.pdf"}'
Body
{"from": "5215500000001","to": "5215500000002","type": "document","link": "https://www.ejemplo.com/ejemplo_documento.pdf","caption": "Este es caption de tipo document","filename": "ejemplo_documento.pdf"}
Video
Petición HTTP
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": "video","link": "https://www.ejemplo.com/ejemplo_video_3.7_MB.mp4"}'
Body
{"from": "5215500000001","to": "5215500000002","type": "video","link": "https://www.ejemplo.com/ejemplo_video_3.7_MB.mp4"}
Sticker
Petición HTTP
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": "sticker","link": "https://www.ejemplo.com/ejemplo_sticker.webp"}'
Body
{"from": "5215500000001","to": "5215500000002","type": "sticker","link": "https://www.ejemplo.com/ejemplo_sticker.webp"}
Audio
Petición HTTP
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": "audio","link": "https://www.ejemplo.com/ejemplo_audio.ogg"}'
Body
{"from": "5215500000001","to": "5215500000002","type": "audio","link": "https://www.ejemplo.com/ejemplo_audio.ogg"}
Mensaje de voz
Petición HTTP
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": "audio","link": "https://www.ejemplo.com/ejemplo_nota_de_voz.ogg","voice": true}'
Body
{"from": "5215500000001","to": "5215500000002","type": "audio","link": "https://www.ejemplo.com/ejemplo_nota_de_voz.ogg","voice": true}
Contenido multimedia con media_id
En lugar de link, se puede enviar el identificador de un archivo previamente cargado en WhatsApp. Aplica para image, video, audio, document y sticker. No se deben enviar link y media_id en la misma petición.
Petición HTTP
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": "image","media_id": "1234567890123456","caption": "Este es el caption de tipo image"}'
Body
{"from": "5215500000001","to": "5215500000002","type": "image","media_id": "1234567890123456","caption": "Este es el caption de tipo image"}
