Upload a file
upload_mediaUploads one file to a WhatsApp number’s media library and returns its media id (med_…), which a message, the number’s profile picture or the AI assistant’s knowledge then takes. The file travels inline as data_base64 with its mime_type, and goes to Meta and to Cosend’s storage in one call. Through an AI app a file is up to 5 MB; a larger video, audio file or document is uploaded in the Cosend dashboard. mime_type decides how WhatsApp sends it: image (jpeg, png), video (mp4, 3gpp), audio (aac, amr, mpeg, mp4, ogg), document (pdf, plain text, Word, Excel and PowerPoint) or sticker (webp). A type WhatsApp does not take, or a file over the limit, is refused before anything is stored. Every upload is its own file on that number, even with the same bytes. The file waits in the media library until a message, the profile or the assistant’s knowledge uses it.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"connection_id": "<connection_id>",
"mime_type": "<mime_type>",
"data_base64": "<data_base64>"
},
"name": "upload_media"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | No | ||
| mime_type | Yes | One of the types WhatsApp accepts, which also decides how the file is sent: image (image/jpeg, image/png; 5 MB), video (video/mp4, video/3gpp; 16 MB), audio (audio/aac, audio/amr, audio/mpeg, audio/mp4, audio/ogg; 16 MB), document (application/pdf, text/plain and the Word, Excel and PowerPoint types; 100 MB), sticker (image/webp; 100 KB static, 500 KB animated). Any other type, or a file over its limit, is refused before anything is stored. | |
| data_base64 | Yes | ||
| connection_id | Yes |