Exhibit A
Follow a media ID from birth to expiry
- Uploaded to Referenced in a send: send by ID
- Uploaded to URL issued: GET /{MEDIA_ID}
- Received to URL issued: GET /{MEDIA_ID}
- URL issued to Downloaded: fetch url with token
- Referenced in a send to Deleted: DELETE /{MEDIA_ID}
- Referenced in a send to Expired: after 30 days
- Received to Expired: after 7 days
- Uploaded
- Referenced in a send
- Expired
Step 3 of 3 · end of walk
Expired
30 days after upload or 7 days after receipt. Sends and lookups with this ID now fail.
Arrived from Referenced in a send via after 30 days.
Can move to
Nothing — this is a final state.
Happy path, step 3 of 3: Expired (via after 30 days). 30 days after upload or 7 days after receipt. Sends and lookups with this ID now fail.
What is a media ID?
A media ID is the identifier the WhatsApp Cloud API gives a file stored on WhatsApp's servers. You get one in two ways: through Media Upload — POST /{PHONE_NUMBER_ID}/media — which returns {"id": "..."}, or by receiving one — when a customer sends a photo, voice note or PDF, the Messages Webhook carries the file's ID inside the message object (image.id, audio.id, document.id and so on) together with its mime_type and sha256.
The ID is a handle, not the file. To send, you reference it in the media object of a Media Message, such as "image": {"id": "{MEDIA_ID}"}, on the messages endpoint — or as a template header parameter. To download it — Media Retrieval — you call GET /{MEDIA_ID}, which returns a short-lived url plus mime_type, sha256 and file_size, then fetch that URL with your access token. To remove a file you uploaded before it lapses, call DELETE /{MEDIA_ID}.
Validity is where teams slip. IDs returned by an upload are kept for 30 days unless you delete them sooner; IDs received in webhooks expire after 7 days, and with them the ability to download that customer's file. The media URL you get from an ID is shorter-lived still, at five minutes. That is the difference between the two: the media ID is a reusable reference that lives for days, while the media URL is a download link that lives for minutes. Nor is it the file handle the Resumable Upload API returns for template sample media: that handle goes into a template definition and cannot be used to send.
Key takeaways
- A media ID identifies a file stored on WhatsApp's servers: you send by referencing it and download by exchanging it for a URL.
- Media IDs from your own uploads stay valid for 30 days; IDs received in inbound webhooks expire after 7 days.
- A media ID is not a link:
GET /{MEDIA_ID}returns a download URL that itself expires after 5 minutes. - One uploaded media ID can be reused across many sends while valid, instead of uploading the same file per recipient.
- Download inbound files promptly — once the ID expires, the customer's file can no longer be fetched.
How does a media ID work?
Upload or receive
Uploading a file to
/{PHONE_NUMBER_ID}/mediareturns an ID that lasts 30 days. An inbound media message delivers an ID in the webhook that lasts 7 days.Send by reference
Put the ID in the media object of a send, e.g.
"document": {"id": "{MEDIA_ID}", "filename": "invoice.pdf"}. The same ID can be used in many sends while it is valid.Resolve it to a URL to download
GET /{MEDIA_ID}returnsurl,mime_type,sha256andfile_size. The URL expires in 5 minutes; ask for a new one if it lapses.Fetch with your token and keep the file
Download the URL with
Authorization: Bearer {ACCESS_TOKEN}— without it the request fails — check the bytes againstsha256, and store the file in your own storage.Delete it or let it expire
DELETE /{MEDIA_ID}removes an uploaded file early and returns{"success": true}. Otherwise the ID simply stops working when its validity ends.
Example: One upload, a week of fee reminders
A Bhopal school uploads its term fee schedule PDF once at 9 am on Monday and stores the returned media ID with an expiry date 30 days out. Its utility template with a document header uses that same ID for all 3,400 parents over the week. When a parent replies with a photo of the payment receipt, the webhook carries a new media ID; the school's worker downloads the file within seconds, checks its hash, attaches it to the student's record and never needs that 7-day ID again.
A media ID in code
curl -X POST "https://graph.facebook.com/v26.0/{PHONE_NUMBER_ID}/messages" \-H "Authorization: Bearer {ACCESS_TOKEN}" \-H "Content-Type: application/json" \-d '{"messaging_product": "whatsapp","to": "919812345678","type": "document","document": {"id": "{MEDIA_ID}","filename": "fee-schedule.pdf","caption": "Term 2 fee schedule"}}'
Common mistakes with a media ID
Storing the ID instead of the file
Inbound IDs expire after 7 days. If your inbox keeps only the ID, customer photos and documents become unrecoverable. Download inbound media on arrival and keep it in your own storage.
Confusing the ID with the URL
Saving the
urlfromGET /{MEDIA_ID}and using it later fails, because it lasts 5 minutes. Keep the ID (while valid) or the downloaded file, never the URL.Re-uploading for every send
Uploading the same brochure once per recipient wastes time and requests. Upload once, cache the ID with its 30-day expiry and reuse it across the campaign.
Using a stale upload ID in a scheduled campaign
A campaign scheduled 35 days after the upload fails on every message. Record the upload date with the ID and re-upload before the 30 days run out.
Why does a media ID matter?
Media IDs make outbound files efficient and inbound files retrievable. A business sending the same brochure to 20,000 customers uploads it once and reuses the ID, instead of uploading 20,000 times or making WhatsApp fetch a public link for every send. On the inbound side, the ID is the only way to get a customer's photo or document at all, and the 7-day expiry means a support system that does not download promptly loses evidence such as damaged-product photos, prescriptions or signed forms.
Best practices for a media ID
- Save the upload timestamp with each media ID and refresh it at around 25 days.
- Verify downloaded bytes against the
sha256from the webhook or the media lookup. - Pass
phone_number_idon lookups and deletes to confirm the file belongs to your number. - Keep a map of file hash to media ID so identical files share one upload.