Media
Upload a file
POST
/mediaScope media:writeUploads a file and returns a mediaHandle to pass to Send a file or to a template's media header. Send it as multipart/form-data with the file in a field called file.
Accepted: JPEG and PNG images, MP4 and 3GP video, audio, PDF and common office documents.
Form fields
Send as multipart/form-data.
filefilerequiredThe file to upload.
Good to know
- A handle only works for the workspace that uploaded it.
- Send the file's type with it (
application/pdf,image/jpegand so on). The type is checked, not guessed from the name, and a file sent asapplication/octet-streamis refused.
Errors
| Status | Code | When |
|---|---|---|
| 400 | BAD_REQUEST | No file, or a type WhatsApp does not accept. |
Plus the errors any endpoint can return, such as a missing key or scope. See Errors.
Request
# macOS, Linux or Git Bash, with WAMAFY_API_KEY set. The quoting does not work in Windows cmd or PowerShell.
curl -X POST "https://api.wamafy.com/api/v1/public/media" \
-H "Authorization: Bearer $WAMAFY_API_KEY" \
-F "file=@invoice.pdf"Response 201
{
"success": true,
"data": {
"mediaHandle": "wamafy-media/4f0c.../9a1e.pdf",
"mimeType": "application/pdf",
"size": 20481,
"filename": "invoice.pdf"
}
}Base URL https://api.wamafy.com/api/v1/public