Send a WhatsApp image: media id or link
Send an image through the CRPRO Hub by media id or HTTPS link: upload step, 5 MB limit, caption, and how audio, video and stickers share the shape.
Images are the most common media message, and they introduce the one decision that applies to every media type: whether to reference the file by an uploaded media id or by a public URL. This tutorial sends an image through the CRPRO Hub in both ways, states the limits that Meta and the Hub impose, and shows how the same shape carries audio, video and stickers.
Should an image be sent by media id or by link?
Short answer: either works, but exactly one of the two must be present. Meta recommends the uploaded media id for better performance, and the Hub rejects a media object that has both id and link, or neither.
The Hub's schema for image, audio, video, document and sticker has the same rule: an object with id or link, never both. The link must be an HTTPS URL, and a plain http:// link fails validation. A media id comes from uploading the file first. Meta describes hosted links as not recommended, because the platform has to fetch the file from your server at send time; an unreachable, slow or redirecting URL turns into a failed message after the POST has already returned.
| Source | Field | Good for | Watch out for |
|---|---|---|---|
| Uploaded file | image.id | Files you generate or hold privately | The id is not permanent; do not store it for later use |
| Public URL | image.link | Files already hosted on a CDN, large files | Must be HTTPS and reachable by Meta when the message is processed |
How is an image sent by URL?
Short answer: set type to image and put an https URL in image.link, with an optional caption of up to 1,024 characters.
curl -X POST https://crprohub.com/api/v1/channels/CHANNEL_UUID/messages \
-H "Authorization: Bearer hub_pk_EXAMPLE_NOT_REAL" \
-H "Idempotency-Key: invoice-1042-photo" \
-H "Content-Type: application/json" \
-d '{
"to": "5521999999999",
"type": "image",
"image": {
"link": "https://cdn.example.com/products/1042.jpg",
"caption": "Your order, packed and ready."
}
}'The response is the same 202 with a message_id as for text. Because the file is fetched later, a bad URL does not make this call fail. It shows up as a failed message.status event, so subscribe to statuses as described in the webhooks reference. For large files the Hub's reference also recommends the HTTPS URL route, since the upload endpoint passes through the Hub host and may have a smaller request size limit than Meta accepts directly.
How is a file uploaded and sent by id?
Short answer: POST the file as multipart/form-data in a field called file to /api/v1/channels/{channelId}/media, then use the returned media_id in image.id.
The upload endpoint is not JSON. It takes multipart/form-data and returns the media id, the MIME type and the size in bytes. The same messages:send scope covers it.
curl -X POST https://crprohub.com/api/v1/channels/CHANNEL_UUID/media \
-H "Authorization: Bearer hub_pk_EXAMPLE_NOT_REAL" \
-F "file=@product.jpg"
# {"data":{"media_id":"1234567890123456","mime_type":"image/jpeg","size":82190}}{
"to": "5521999999999",
"type": "image",
"image": {
"id": "1234567890123456",
"caption": "Your order, packed and ready."
}
}Do not keep the media id in your database for reuse next month. The Hub's reference warns that it disappears within days, and Meta's media documentation gives uploaded files a limited lifetime of their own (30 days unless you delete them earlier). Treat an id as a short-lived handle: upload, send, forget. If the same picture goes out every day, a stable HTTPS URL is easier to operate.
Which formats and sizes does WhatsApp accept?
Short answer: JPEG and PNG up to 5 MB for images, and the image must be 8-bit RGB or RGBA. Captions are limited to 1,024 characters.
The Hub documents the same ceilings in its limits table: images 5 MiB, stickers 500 KiB, audio and video 16 MiB, documents 100 MiB. Meta's media reference adds the format detail: images are JPEG or PNG, audio is AAC, AMR, MP3, M4A or OGG with Opus in mono, video is 3GP or MP4, and stickers are WebP, with static stickers capped at 100 KB and animated ones at 500 KB. A file that violates these constraints is typically refused by Meta after the upload or at send time.
- Image: JPEG or PNG, 5 MB, caption up to 1,024 characters.
- Video: 3GP or MP4, 16 MB, caption up to 1,024 characters.
- Audio: 16 MB, no caption field in the Hub schema.
- Sticker: WebP, no caption field; 100 KB static, 500 KB animated.
How can a failed media message be detected?
Short answer: through the message.status event with status failed, which carries an error code. The synchronous response never reports a media problem that Meta finds after accepting the request.
A reliable client therefore keeps a small record per send: the message_id returned by the Hub, the business event that caused it and the time it was sent. When a failed status arrives, the record tells you which order, invoice or ticket the picture belonged to, and your code can decide between resending with a different source (for example, uploading the file instead of using a URL) and alerting a person. Retrying a failed media send with the same Idempotency-Key returns the original response and sends nothing, so a deliberate resend needs a new key. That detail catches many first integrations: the retry looks like it worked, because the 202 comes back, but no new message left the system.
Does the same payload work for audio, video and stickers?
Short answer: yes. Change type and the name of the object; the id-or-link rule is identical. Only images, videos and documents accept a caption.
{ "to": "5521999999999", "type": "video",
"video": { "link": "https://cdn.example.com/demo.mp4", "caption": "Setup walkthrough" } }
{ "to": "5521999999999", "type": "audio",
"audio": { "id": "1234567890123457" } }
{ "to": "5521999999999", "type": "sticker",
"sticker": { "id": "1234567890123458" } }The Hub's schema rejects a caption on audio and sticker objects because those objects are strict and define no such field. Remember that all of these are free-form messages: outside the 24-hour window they need a template, even though the POST itself is accepted with a 202. The first authenticated call is shown in the quickstart.
Where should the image files live?
Short answer: on storage you control, behind HTTPS, with URLs that stay valid longer than the delivery attempt needs.
Sending by link moves a responsibility onto your infrastructure: Meta has to fetch the file at processing time. Signed URLs with a very short expiry, files behind a login and servers that throttle unknown clients all lead to failed statuses that are hard to reproduce from your side. A public bucket path or a CDN URL with an expiry measured in hours removes most of those surprises. Uploading by media id removes the dependency but adds a step and a short-lived identifier, so choose per workload rather than globally.
- Use HTTPS only; the Hub refuses plain HTTP links.
- Serve the correct Content-Type, and avoid redirects to interstitial pages.
- Keep the image within 5 MB and in JPEG or PNG format.
- Put the order, invoice or ticket reference in the file name so logs are readable.
- Log the message_id with the URL used, to match later failed statuses.
Frequently asked questions
Can id and link both appear in the same image object?
No. The Hub requires exactly one of the two, and Meta's reference says to omit the field you do not use. A payload with both, or with neither, fails validation with 400 INVALID_MESSAGE.
Why does an image request return 202 when the customer never sees the image?
The 202 only means the message was accepted and queued. A URL that Meta cannot fetch, an unsupported format or a file over the size limit shows up afterwards as a failed message.status event with an error code.
Is an HTTP image URL accepted?
No. The Hub's schema only accepts https URLs for the link field. Host the file behind HTTPS or upload it and send the media id.
How long does an uploaded media id stay valid?
Treat it as short-lived. The Hub's reference says it disappears within days, and Meta documents a 30-day lifetime for uploaded files unless deleted sooner. Upload close to the moment you send.
Fontes
Documentação oficial da Meta, conferida em 31 de outubro de 2026.