Skip to main content

Media upload and download

Plan: LUMA Elevate or Enterprise. Credits: free (a media message inside the 24-hour window is free; a template costs 12 credits).

Upload a file to send​

Upload once, then send it by id as often as you like (WhatsApp keeps uploaded media for 30 days).

POST /v1/{phoneNumberId}/media (multipart/form-data)

curl --request POST 'https://api.itechintl.com/v1/PHONE_NUMBER_ID/media' \
--header 'Authorization: Bearer lm_live_YOUR_API_KEY' \
--form 'messaging_product=whatsapp' \
--form 'type=application/pdf' \
--form 'file=@Invoice-1001.pdf'
Form fieldRequiredDescription
fileyesThe file
typeyesThe file's MIME type, for example image/jpeg, video/mp4, audio/ogg, application/pdf
messaging_productyesAlways whatsapp

Response 200

{ "message": "Success", "data": { "id": "MEDIA_ID" } }

Then send it:

{ "from": "971500000000", "to": "971500000001", "type": "document",
"document": { "id": "MEDIA_ID", "filename": "Invoice-1001.pdf" } }

Size and format limits are listed in Send messages. Instead of uploading, you can also send a public HTTPS link.

Download a file a customer sent​

When a customer sends a photo, voice note, video or document, the incoming message contains the media id and a media url. Download it through LUMA (the URL needs your number's access, which LUMA adds for you):

GET /v1/{phoneNumberId}/media?url=MEDIA_URL

curl --get 'https://api.itechintl.com/v1/PHONE_NUMBER_ID/media' \
--data-urlencode 'url=MEDIA_URL' \
--header 'Authorization: Bearer lm_live_YOUR_API_KEY' \
--output customer-photo.jpg

The response is the file itself, with its Content-Type. Download media soon after you receive it: WhatsApp media links expire.

Errors​

StatusWhen
400phoneNumberId or url missing, or the file is not accepted by WhatsApp
401, 403Key or plan problem
404The number is not connected to your organization