Sending
Upload a file
Post the bytes, get an id, send by id. For files that do not already live at a public URL.
When you need this
Sending a file takes either a public link or an id. A link is simpler and needs nothing from this page: if the invoice is already on your site, hand WhatsApp the URL and you are done.
This endpoint is for everything else — a PDF generated in memory, a file in a private bucket, anything behind an auth check. Publishing it somewhere public just so WhatsApp can fetch it is a storage problem you should not have to solve to send one document.
The request
The body is the file. No multipart, no form encoding — one file per request, so the envelope would carry nothing.
curl -X POST https://sendrixbackend.exebee.com/v1/media \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/pdf" \
-H "X-File-Name: invoice-4471.pdf" \
--data-binary @invoice-4471.pdfHTTP/1.1 201 Created
{
"id": "1024559372847361",
"object": "media",
"type": "document",
"mime": "application/pdf",
"filename": "invoice-4471.pdf",
"size_bytes": 48213,
"sender_id": "snd_9c1f2b4e-...",
"expires_at": "2026-10-02T11:14:02.000Z"
}Requires the messages:send scope. Then use that id on a send:
{
"to": "919833663235",
"template": {
"name": "order_invoice",
"variables": { "1": "Asha" },
"header_media": { "id": "1024559372847361" }
}
}Headers and parameters
| Required | Notes | |
|---|---|---|
Content-Type | yes | The file's own type. This is how we know what kind of message it becomes, so application/octet-stream is refused. |
X-File-Name | documents | What the recipient sees under the file. Percent-encode anything outside ASCII. Ignored on images, video and audio, which WhatsApp shows without a name. |
?sender_id | no | Which number to upload for. Omit it and your default is used. |
What it accepts
| Kind | Types | Ceiling |
|---|---|---|
| image | image/jpeg | 5 MB |
image/png, image/webp | ||
| video | video/mp4, video/3gpp | 16 MB |
| audio | audio/aac, audio/mpeg, audio/ogg, audio/mp4 | 16 MB |
| document | application/pdf, Word, Excel, PowerPoint, text/plain | 100 MB |
The ceilings are WhatsApp’s, and they are checked before the upload starts — an oversized image is told so immediately rather than after pushing the whole thing across the wire. A type not on this list gets 415 unsupported_media_type, and the error lists everything that is.
Which to use
- A link when the file is already public and stable. One request instead of two, and nothing expires.
- An id when the file is not public, or when the same file goes to many people — one upload then serves every send, instead of WhatsApp fetching the URL once per message.