Get message media
Get a short-lived download URL for the image, video, audio, document, or sticker of a message.
/v1/messaging/messages/{messageId}/mediaMedia files are never linked from message objects or webhooks. Request a URL when you need the file, download it right away, and don't store the URL.
Authorization
Bearer token
- Authorizationrequiredheader
Send your API key as
Bearer YOUR_API_KEY.
Path parameters
messageIdrequiredstringID of a message with media, starting with
msg_: an image, video, audio, document, or sticker, or a template with a media header.
Query parameters
expiresInSecondsoptionalintegerHow long the URL works, from
30to3600seconds. Default300.
Response
Example identifiers below are illustrative.
message_idstringThe message ID.
urlstringWhere to download the file: a short-lived URL, or the link you sent the file by.
expires_atstring or nullWhen
urlstops working.nullfor a link you sent the file by.mime_typestring or nullThe file type, such as
image/jpeg.size_bytesnumber or nullThe file size in bytes.
nullfor a link you sent the file by.filenamestring or nullThe file name, when known.
Errors
| Status | code | Returned when |
|---|---|---|
400 | none | expiresInSeconds is not a whole number from 30 to 3600. |
401 | none | The API key is missing, malformed, revoked, or expired. |
403 | none | The key lacks the whatsapp.send permission. |
403 | FEATURE_NOT_AVAILABLE | WhatsApp is not turned on for your organization. |
404 | message_not_found | No message with this ID exists in the key's project, it was deleted after 30 days, or it is a received message and the key lacks whatsapp.full_access. |
404 | whatsapp_media_not_found | The message has no media file, or the file was deleted. |
409 | whatsapp_media_pending | The file a customer sent is still being downloaded from WhatsApp. |
409 | whatsapp_media_unavailable | The file a customer sent could not be downloaded from WhatsApp. |