Skip to main content

WhatsApp: Send

Send one or more WhatsApp messages, with optional media, via the Mersal API.

3 min read

Send one or more WhatsApp messages in a single request. The request shape mirrors SMS: Send, with additional optional fields for attaching media to a message.

Endpoint

POSThttps://mersal.it/api/whatsapp/send

Authentication

Requires your personal API key via the Api-key header (or the api_key query/body fallback). See Authentication.

Request parameters

NameTypeRequiredDescription
contactarrayYesArray of recipients. Must contain at least 1 item.
contact.*.numberstringYesThe recipient's WhatsApp number.
contact.*.messagestringYesThe message body.
contact.*.gateway_identifierstringNoUID of a specific WhatsApp gateway to send through (e.g. a specific WhatsApp Cloud API connection or QR-linked device). Omit to use your account's default/active WhatsApp gateway.
contact.*.schedule_atstringNoSchedule delivery for a future time, format Y-m-d H:i:s. Omit to send immediately.
contact.*.mediastringNoMedia type to attach: one of image, audio, video, document.
contact.*.urlstringNoPublic URL of the media file to send. Required when media is set.
contact.*.filenamestringNoDisplay filename for document media.

For interactive list messages (WhatsApp list picker UI), use the separate POST /api/whatsapp/send-list endpoint.

Example request

curl -X POST https://mersal.it/api/whatsapp/send \
  -H "Api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contact": [
      {
        "number": "+201234567890",
        "message": "Here is your invoice.",
        "media": "document",
        "url": "https://example.com/files/invoice-1042.pdf",
        "filename": "invoice-1042.pdf"
      }
    ]
  }'

Example response

{
  "success": true,
  "message": "WhatsApp message queued successfully",
  "data": {
    "contact": [
      {
        "number": "+201234567890",
        "status": "queued"
      }
    ]
  }
}

On validation failure, Mersal returns 422:

{
  "success": false,
  "message": "Validation failed",
  "errors": {
    "contact.0.message": ["The contact.0.message field is required."]
  }
}

Errors

Common failure modes are a missing/invalid API key, an expired subscription, or a 422 validation error on the contact array (including invalid media/url combinations). See Errors and Status Codes for the full reference.

Was this page helpful?
WhatsApp: Send · Mersal Docs