Messages
Send a file
/messages/mediaScope messages:sendSends a file up to 16 MB. Give either a public link we fetch, or a mediaHandle from Upload a file. Only works inside the 24-hour window.
Body
tostringrequiredRecipient phone number with country code, for example
+919876543210. Spaces and dashes are ignored. A number without a country code is not guessed at and will not reach anyone.fromstringWhich of your WhatsApp numbers to send from. Accepts the number itself, its Meta
phone_number_idor its Wamafy id. Defaults to your default number.linkstringPublic URL of the file. We download it when you send, so it must be reachable without a login.
mediaHandlestringHandle returned by Upload a file.
captionstringText shown with the file. Up to 1,024 characters.
filenamestringFile name shown for a document.
Errors
| Status | Code | When |
|---|---|---|
| 400 | NO_OPEN_CONVERSATION | The window is closed. Send a template instead. |
| 400 | MEDIA_TOO_LARGE | The file is over 16 MB. |
| 400 | MEDIA_FETCH_FAILED | Downloading the link failed, for example it answered 404. |
| 400 | MEDIA_URL_REJECTED | The link points somewhere we will not fetch from, such as a private address. |
| 400 | MEDIA_TOO_LARGE | The file is over 16 MB. |
| 403 | MEDIA_FORBIDDEN | The mediaHandle belongs to another workspace. |
| 422 | VALIDATION_ERROR | Both link and mediaHandle were sent, or neither. |
Plus the errors any endpoint can return, such as a missing key or scope. See Errors.
# 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/messages/media" \
-H "Authorization: Bearer $WAMAFY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+919876543210",
"link": "https://wamafy.com/smoke/sample.pdf",
"caption": "Your invoice",
"filename": "INV-1043.pdf"
}'{
"success": true,
"data": {
"messageId": "wamid.HBgMOTE5ODc2NTQzMjEwFQIAERgSOUQ",
"conversationId": "2b7e4f10-8c3a-4d2e-b1f6-0a9c5e7d3b21",
"status": "sent"
}
}Base URL https://api.wamafy.com/api/v1/public