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.

shell
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.pdf
json
HTTP/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:

json
{
  "to": "919833663235",
  "template": {
    "name": "order_invoice",
    "variables": { "1": "Asha" },
    "header_media": { "id": "1024559372847361" }
  }
}

Headers and parameters

RequiredNotes
Content-TypeyesThe file's own type. This is how we know what kind of message it becomes, so application/octet-stream is refused.
X-File-NamedocumentsWhat the recipient sees under the file. Percent-encode anything outside ASCII. Ignored on images, video and audio, which WhatsApp shows without a name.
?sender_idnoWhich number to upload for. Omit it and your default is used.

What it accepts

KindTypesCeiling
imageimage/jpeg5 MB
image/png, image/webp
videovideo/mp4, video/3gpp16 MB
audioaudio/aac, audio/mpeg, audio/ogg, audio/mp416 MB
documentapplication/pdf, Word, Excel, PowerPoint, text/plain100 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.