Messages

Send a file

POST/messages/mediaScope messages:send

Sends 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

  • tostringrequired

    Recipient 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.

  • fromstring

    Which of your WhatsApp numbers to send from. Accepts the number itself, its Meta phone_number_id or its Wamafy id. Defaults to your default number.

  • linkstring

    Public URL of the file. We download it when you send, so it must be reachable without a login.

  • mediaHandlestring

    Handle returned by Upload a file.

  • captionstring

    Text shown with the file. Up to 1,024 characters.

  • filenamestring

    File name shown for a document.

Errors

StatusCodeWhen
400NO_OPEN_CONVERSATIONThe window is closed. Send a template instead.
400MEDIA_TOO_LARGEThe file is over 16 MB.
400MEDIA_FETCH_FAILEDDownloading the link failed, for example it answered 404.
400MEDIA_URL_REJECTEDThe link points somewhere we will not fetch from, such as a private address.
400MEDIA_TOO_LARGEThe file is over 16 MB.
403MEDIA_FORBIDDENThe mediaHandle belongs to another workspace.
422VALIDATION_ERRORBoth 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"
}'
Response 200
{
  "success": true,
  "data": {
    "messageId": "wamid.HBgMOTE5ODc2NTQzMjEwFQIAERgSOUQ",
    "conversationId": "2b7e4f10-8c3a-4d2e-b1f6-0a9c5e7d3b21",
    "status": "sent"
  }
}

Base URL https://api.wamafy.com/api/v1/public

    Send a file - Wamafy API