logo
enes

Media

Last update: 6 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: "image", "document", "video", "sticker", "audio"
  • Response: the same for every message (see response)

Messages with an attached file: image, document, video, sticker, audio, or voice message. All are sent with POST /v1/messaging; headers, common fields and the response are in HTTP connection.

Media

Sends a file by its URL (link) or by its WhatsApp ID (media_id). The type field sets the file type: audio, document, image, sticker, or video.

Body

Fields for Media, in addition to the common fields:

NameDescriptionTypeRequirements
typeMedia type. Possible values: audio, document, image, sticker, and video.StringRequired.
linkURL of the file. The URL must be publicly reachable and the file must not exceed the maximum size allowed for your number.String
  • Required if media_id is not sent.
  • Can't be sent together with media_id.
media_idID of a media file previously uploaded to WhatsApp. Use it instead of link.String
  • Required if link is not sent.
  • Can't be sent together with link.
filenameFile name.String
  • Optional.
  • Only used in the document object.
captionFile description.String
  • Optional.
  • Only used with image, video and document. Ignored for audio and sticker.
voiceIf true, the audio is sent as a voice message (voice note) instead of an audio file.Boolean
  • Optional.
  • Only used with type audio.

Examples

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": "image",
"link": "https://www.ejemplo.com/ejemplo_imagen.png",
"caption": "This is an image caption"
}'

Body

{
"from": "5215500000001",
"to": "5215500000002",
"type": "image",
"link": "https://www.ejemplo.com/ejemplo_imagen.png",
"caption": "This is an image caption"
}

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": "document",
"link": "https://www.ejemplo.com/ejemplo_documento.pdf",
"caption":"This is a document caption",
"filename":"ejemplo_documento.pdf"
}'

Body

{
"from": "5215500000001",
"to": "5215500000002",
"type": "document",
"link": "https://www.ejemplo.com/ejemplo_documento.pdf",
"caption": "This is a document caption",
"filename": "ejemplo_documento.pdf"
}

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": "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

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": "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

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": "audio",
"link": "https://www.ejemplo.com/ejemplo_audio.ogg"
}'

Body

{
"from": "5215500000001",
"to": "5215500000002",
"type": "audio",
"link": "https://www.ejemplo.com/ejemplo_audio.ogg"
}

Voice message

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

Media with media_id

Instead of link, you can send the ID of a file previously uploaded to WhatsApp. This applies to image, video, audio, document, and sticker. Don't send link and media_id in the same request.

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": "image",
"media_id": "1234567890123456",
"caption": "This is an image caption"
}'

Body

{
"from": "5215500000001",
"to": "5215500000002",
"type": "image",
"media_id": "1234567890123456",
"caption": "This is an image caption"
}


Previous
Text messages
Next
Location