media_id),
retrieve the download URL of a media file (for inbound messages), and delete media you no
longer need. See Media by URL vs Media ID for
when to use media ID vs URL in outbound messages.
1. Upload media (get a media_id)
id in the image.id, document.id, video.id, etc. field of any message. Media
IDs expire after 30 days.
2. Retrieve media URL (to download received media)
When a webhook delivers an inbound media message, the payload contains amedia_id. Use this
to get the download URL:
3. Delete media
Frequently asked
How do I upload a file to WhatsApp before sending it?
How do I upload a file to WhatsApp before sending it?
Send a
multipart/form-data POST to /{phone-number-id}/media with
messaging_product=whatsapp, the file bytes, and the MIME type. Meta returns a media_id
to use in your message.How do I download a file from a WhatsApp message my bot received?
How do I download a file from a WhatsApp message my bot received?
The inbound webhook gives you a
media_id. Call GET /{media_id} to get a temporary
download URL, then download the file using that URL with your Authorization header.How long does a media ID last?
How long does a media ID last?
30 days. After that the ID stops working and you must re-upload the file to get a new ID.
How do I delete media I uploaded?
How do I delete media I uploaded?
Call
DELETE /{media_id} with your Authorization header. Returns {"deleted": true} on
success.
