Media

Upload a file

POST/mediaScope media:write

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

  • filefilerequired

    The 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/jpeg and so on). The type is checked, not guessed from the name, and a file sent as application/octet-stream is refused.

Errors

StatusCodeWhen
400BAD_REQUESTNo file, or a type WhatsApp does not accept.

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/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

    Upload a file - Wamafy API