POST /v1/{phone_number_id}/media
Uploads a file to WhatsApp and returns its media id. Use it as image.id, video.id,
audio.id, document.id or sticker.id in a message send, or as
the media of a template header.
Upload when the file isn’t publicly reachable, or when you’ll send the same file many times.
Otherwise you can pass a public link in the send itself and skip this step.
The path, request and response are the same as the WhatsApp Cloud API’s
POST /{phone_number_id}/media. Code written for Meta works by changing only the base URL and
the key.
POST /v1/{phone_number_id}/mediaAuthorization: Bearer hello_live_xxxxxxxxxxxxxxxxContent-Type: multipart/form-datacurl -X POST "$HELLO_API_URL/v1/$PHONE_NUMBER_ID/media" \ -H "Authorization: Bearer $HELLO_API_KEY" \ -F "messaging_product=whatsapp" \ -F "type=application/pdf" \ -F "file=@./Invoice INV-2291.pdf"Path parameters
Section titled “Path parameters”| Parameter | Type | Description |
|---|---|---|
phone_number_id |
string | The sending number’s WhatsApp phone number ID, from the Accounts page or GET /v1/phone_numbers. The media can only be sent from this number. |
Form fields
Section titled “Form fields”| Field | Type | Required | Description |
|---|---|---|---|
messaging_product |
string | Yes | Always whatsapp |
type |
string | Yes | The file’s MIME type, for example image/jpeg or application/pdf |
file |
file | Yes | The file. Its file name is the name recipients see for documents. |
If type isn’t a type WhatsApp supports, Hello tries the file’s extension, then its contents.
A file whose contents clearly contradict its type is rejected. See
supported media for allowed types and sizes.
Response 200
Section titled “Response 200”{ "id": "1099999999993456" }A media id is valid for about 30 days, and only for the number it was uploaded under.
Send it from the same phone_number_id.
Errors
Section titled “Errors”Errors use the same envelope as Meta’s Cloud API: error.code is WhatsApp’s own code when
WhatsApp rejected the file, otherwise Meta’s code for the same situation, and Hello’s own code is
in error.error_data.hello_code. See Errors for every field.
{ "error": { "message": "type is required: the file's MIME type, e.g. image/jpeg", "type": "OAuthException", "code": 100, "error_data": { "messaging_product": "whatsapp", "details": "type is required: the file's MIME type, e.g. image/jpeg", "hello_code": "VALIDATION_ERROR" }, "fbtrace_id": "3f9c2a1e-7b4d-4c8e-9a15-2d6f8e0b1c47" }}| Status | hello_code |
error.code |
Cause |
|---|---|---|---|
400 |
VALIDATION_ERROR |
100 |
phone_number_id isn’t numeric, messaging_product isn’t whatsapp, or type is missing |
400 |
MISSING_FILE |
100 |
No file part, or the body isn’t multipart/form-data |
400 |
INVALID_MEDIA |
100 |
Unsupported type, file too large or empty, or contents that don’t match the type |
401 |
UNAUTHORIZED |
190 |
Missing, wrong or disabled API key |
404 |
ACCOUNT_NOT_FOUND |
100 (subcode 33) |
No number with this phone_number_id in your organization |
409 |
ACCOUNT_NOT_REGISTERED |
133010 |
The number hasn’t completed phone registration |
413 |
PAYLOAD_TOO_LARGE |
100 |
The request body is larger than the server allows |
4xx |
UPLOAD_REJECTED |
WhatsApp’s own | WhatsApp rejected the file. message has WhatsApp’s explanation. |
502 |
UPLOAD_REJECTED |
131000 |
WhatsApp rejected Hello’s credentials for this number. Contact support. |
502 |
META_UNAVAILABLE |
2 |
WhatsApp was unreachable. Retry. |
500 |
UPLOAD_FAILED |
131000 |
Temporary error. Retry. |