Links

Upload, retrieve or delete media

Use the media node to upload, retrieve, or delete media.
To send media such as images, documents, audio or video you must first Upload the Media and then Send it.

If the WABA is registered in On-premise API

When a media message is sent, the media is stored on the WhatsApp servers for 14 days. We also store media on our servers for 14 days. If a user makes a request to download the media after 14 days, they will be notified that the media is unavailable.
It is a good practice for partners and clients to store any media in their own servers and delete them from our servers immediately after.

Constraints

  • If you use the media upload process rather than linking to a media URL, the file must be uploaded to the media volume. Once the upload is complete, you can send a message using the media ID.
  • The application processes the media that is uploaded before it's sent to the server. While the maximum file size for media that can be uploaded to the media node is 64MB, there are post-processing limits for the various media types outlined in the Post-Processing Media Size table.
  • Media storage is handled by 360dialog. If the media volume gets full, message sending will start to fail.
  • There is no support for:
    • Sending media by byte streams.
    • Sending messages with animated stickers.
Note: If a request to the GET/media endpoint returns a status code of 400 or higher, please ensure that it is not retried more than 5 times to prevent performance degradation and potential server overload. It's recommended to investigate the cause of the error and address it before attempting to make the request again. If any inconstancy occurs, please contact our Support Team at the earliest.

Endpoints

post
https://waba.360dialog.io
/v1/media
Upload Media
Content-Type: image/jpeg or other appropriate media type your-binary-media-data
get
https://waba.360dialog.io
/v1/media/{media_id}
Get Media
delete
https://waba.360dialog.io
/v1/media/{media-id}
Delete media

Supported Media Types

Media
Supported Content-Types
audio
audio/aac, audio/mp4, audio/amr, audio/mpeg, audio/ogg; codecs=opus Note: The base audio/ogg type is not supported.
document
Any valid MIME-type.
image
image/jpeg, image/png
sticker
image/webp
video
video/mp4, video/3gpp
Notes:
Only H.264 video codec and AAC audio codec is supported. Only videos with a single audio stream are supported.

If the WABA is registered in Cloud API

The media hosting is managed by Meta for numbers in the Cloud API. Please refer to Meta's Official Documentation for clarification on their regulations.
All media files sent through this endpoint are encrypted and persist for 30 days, unless they are deleted earlier.

Constraints

  • If you use the media upload process rather than linking to a media URL, the file must be uploaded to the media volume. Once the upload is complete, you can send a message using the media ID.
  • The maximum supported file size for media messages on Cloud API is 100MB. In the event the customer sends a file that is greater than 100MB, you will receive a webhook with an error.
  • There are various size limits for media types outlined in the Supported Media Types table.
Note: If a request to the GET/media endpoint returns a status code of 400 or higher, please ensure that it is not retried more than 5 times to prevent performance degradation and potential server overload. It's recommended to investigate the cause of the error and address it before attempting to make the request again. If any inconstancy occurs, please contact our Support Team at the earliest.

Endpoints

post
https://waba-v2.360dialog.io
/media
Upload Media
To retrieve a media you need to use an endpoint to retrieve the URL and submit get again with the URL received:
get
https://waba-v2.360dialog.io/
{media-id}
Get Media
delete
https://waba-v2.360dialog.io/
{media-id}
Delete Media

Retrieve Media URL

You can use the returned URL to download the media file obtained from previous endpoint.
So for the response you obtain, delete the root hostname https://lookaside.fbsbx.com and a attach the rest /whatsapp_business/attachments/?mid=130345565692730173924&ext=1664537344507&hash=ATtBt0Cdio to our root url https://waba-v2.360dialog.io.
Payload Example to Download media:
curl -X GET 'waba-v2.360dialog.io/whatsapp_business/attachments/?mid=130345565692730173924&ext=1664537344507&hash=ATtBt0Cdio' -H 'D360-API-KEY: YOUR_API_KEY' > media_file
Please treat the postfix of this message as secret. This link will be valid for 5 mins.
Depending on your cURL version you may receive a BINARY response instead of the expected JSON. In this case please add the --compressed flag to your cURL query.

Supported Media Types

Please refer to Meta's Official Documentation for Supported Media Types table.

Recommendations

When sending messages with media such as images, videos, or audio files, it is important to ensure that they are not heavy, as processing heavy media files at once can cause delays in transmission and lead to issues with message delivery.
For this, we suggest uploading media beforehand using the /media endpoint and then utilizing the media_id obtained from the response when sending messages.
By following this approach, you can ensure that the media file is processed accurately without causing any delays or latencies during send-outs.
Official WhatsApp API Documentation: https://developers.facebook.com/docs/whatsapp/api/media/