Media
Whitelabel WhatsApp Cloud API keeps its own copy of every WhatsApp file, inbound and outbound, and gives you a signed URL. You never need the business's Meta token.
Scopes: media:read for reads, media:write for uploads, retries and deletes.
Receive a file
- The customer sends a photo, voice note, video, document or sticker.
message.receivedarrives at once. It is Meta's change, unchanged: the media object has Meta'sid, not a file.- Whitelabel WhatsApp Cloud API downloads the file from Meta, stores it, and (for audio, when transcription is on) transcribes it.
message.media_readyarrives with a signedurl.
{
"event": "message.media_ready",
"tenantId": "ck_tenant",
"customerId": "ck_customer",
"phoneNumberId": "ck_phone",
"data": {
"mediaAssetId": "ck_asset",
"messageId": "ck_message",
"wamId": "wamid.HBgM...",
"conversationId": "ck_conversation",
"origin": "inbound",
"direction": "INBOUND",
"kind": "audio",
"status": "STORED",
"waMediaId": "1234567890",
"mimeType": "audio/ogg",
"byteSize": 51200,
"sha256": "69da8b7d…",
"filename": null,
"caption": null,
"transcript": { "text": "Hola, necesito ayuda con mi pedido", "language": "spanish", "provider": "groq:whisper-large-v3-turbo" },
"url": "https://example.com/whatsapp/…?X-Amz-Signature=…",
"urlExpiresAt": "2026-10-21T20:00:00.000Z",
"storedAt": "2026-10-21T19:00:00.000Z",
"expiresAt": null
}
}- Join on
wamId(ormessageId) to themessage.receivedyou already stored. urlis time-limited (MEDIA_SIGNED_URL_TTL_SECS, default 1 hour). StoremediaAssetId, not the URL; ask for a fresh URL when you need one.transcriptisnullunless the deployment turned transcription on. Imported history audio staysnullunless the operator setsHISTORY_SYNC_TRANSCRIBE=true.- After the last retry fails you get
message.media_failedwith the same fields,status: "FAILED",errorandurl: null. Retry it withPOST /api/v1/media/assets/:id/retry. Imported history does not sendmessage.media_failed. - Outbound media you send (by
idorlink) and files the business sends from the WhatsApp Business app (coexistence echoes) are copied too, withdirection: "OUTBOUND". - Imported history files (
originhistory_sync) are copied into storage and do not sendmessage.media_readyormessage.media_failed. - When the deployment or tenant has no storage configured, no copy is made and
message.media_readyis not sent. The Meta proxy below still works.
Read a stored file
GET /api/v1/media/assets/:idReturns the fields above plus a fresh url and urlExpiresAt.
GET /api/v1/media/assets/:id/content302 to a 5-minute signed URL. Handy as an <img src> behind your own auth proxy.
GET /api/v1/media/assets?messageId=&phoneNumberId=&status=&page=1&limit=50status is PENDING, STORED, FAILED, DELETING (delete in progress: stored object not yet removed, or a copy still in flight) or DELETED. Newest first.
POST /api/v1/media/assets/:id/retry
DELETE /api/v1/media/assets/:idRetry queues a FAILED (or stuck PENDING) copy again: 202. Delete removes the stored copy now: 204. It does not touch Meta's copy. If a copy is still in flight the asset stays DELETING until that copy finishes and is removed. Retrying a DELETING asset returns 400.
Upload a file to send
Meta needs a media id (or a public link) in the send body. Upload first:
POST /api/v1/media?phoneNumberId=PHONE_ID
Authorization: Bearer $VITRAL_WHATSAPP_API_KEY
Content-Type: multipart/form-data; boundary=…
[email protected]- Multipart: a
filepart. Optional text fieldstype(MIME type, otherwise the part's type) andkind(image,video,audio,document,sticker). - Or send the raw bytes with the file's
Content-Typeand optional?filename=and?kind=.
201:
{ "data": { "mediaId": "1234567890", "mimeType": "application/pdf", "byteSize": 48211, "sha256": "…", "filename": "factura.pdf", "kind": "document" } }Then send with "document": { "id": "1234567890", "filename": "factura.pdf" }.
Size limits are checked before Meta is called (400 VALIDATION_ERROR with details.maxBytes):
| Kind | Limit | Types |
|---|---|---|
| image | 5 MB | image/jpeg, image/png |
| sticker | 500 KB | image/webp |
| audio | 16 MB | audio/aac, audio/amr, audio/mpeg, audio/mp4, audio/ogg |
| video | 16 MB | video/mp4, video/3gpp |
| document | 100 MB | anything else |
From a URL
POST /api/v1/media/from-url
Content-Type: application/json
{ "phoneNumberId": "PHONE_ID", "url": "https://example.com/menu.pdf", "filename": "menu.pdf" }Whitelabel WhatsApp Cloud API fetches the URL once and uploads it. Only public http(s) addresses are fetched: loopback, private, link-local and cloud-metadata addresses are refused, including through redirects or DNS that changes between lookups. Pass mimeType when the server does not send a useful Content-Type.
Meta media proxy
These call Meta directly and keep nothing:
GET /api/v1/media/:mediaId?phoneNumberId= (Meta's URL info)
GET /api/v1/media/:mediaId/download?phoneNumberId= (bytes, while Meta still has the file)
DELETE /api/v1/media/:mediaId?phoneNumberId=Prefer the stored copy: Meta removes media after a limited time.
Storage usage
GET /api/v1/usage/mediaScope usage:read. Stored files, bytes and transcribed files per phone number with its customerId, plus totals. Use it to rebill storage to your businesses.