Skip to content

Messages ​

All send endpoints are POST with a JSON body. They share these fields:

FieldType
sessionstringThe session (linked number) to send from.
tostringPhone number with country code (6281234567890), group id, or full JID.
is_groupbooleanOptional. Set true when to is a group id.

Before sending, the gateway checks that a phone number is registered on WhatsApp and answers 400 6281234567890 is not registered on WhatsApp if it isn't. Anything in to that isn't a number, group id or JID (a name, an email, a username) is rejected right away. WhatsApp usernames are not supported.

The response contains the sent message. Its key.id is the message ID you'll see again in message.status webhooks:

json
{
  "data": {
    "key": { "remoteJid": "6281234567890@s.whatsapp.net", "fromMe": true, "id": "3EB0C4F1A2B3D4E5" },
    "message": { "extendedTextMessage": { "text": "Hello" } },
    "messageTimestamp": "1764584460"
  }
}

Before sending text, images, videos and documents, the number shows typing… for a moment (up to 5 seconds, depending on the text length), like a person would.

Media URLs

Media is sent from a public http(s) URL: the gateway downloads it and uploads it to WhatsApp. Local file paths are not accepted.

Send text ​

http
POST /message/send-text
json
{ "session": "sales", "to": "6281234567890", "text": "Your order #1042 has shipped πŸ“¦" }
bash
curl -X POST http://YOUR_SERVER:5001/message/send-text \
  -H "key: wag_your_key" -H "content-type: application/json" \
  -d '{"session":"sales","to":"6281234567890","text":"Your order #1042 has shipped πŸ“¦"}'
js
await fetch("http://YOUR_SERVER:5001/message/send-text", {
  method: "POST",
  headers: { key: "wag_your_key", "content-type": "application/json" },
  body: JSON.stringify({ session: "sales", to: "6281234567890", text: "Your order #1042 has shipped πŸ“¦" }),
});
python
import requests

requests.post(
    "http://YOUR_SERVER:5001/message/send-text",
    headers={"key": "wag_your_key"},
    json={"session": "sales", "to": "6281234567890", "text": "Your order #1042 has shipped πŸ“¦"},
)
php
$ch = curl_init('http://YOUR_SERVER:5001/message/send-text');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ['key: wag_your_key', 'content-type: application/json'],
    CURLOPT_POSTFIELDS => json_encode(['session' => 'sales', 'to' => '6281234567890', 'text' => 'Your order #1042 has shipped πŸ“¦']),
]);
$response = curl_exec($ch);

To a group:

json
{ "session": "sales", "to": "120363012345678901", "is_group": true, "text": "Hello team" }

Send image ​

http
POST /message/send-image
json
{
  "session": "sales",
  "to": "6281234567890",
  "text": "Here's your receipt",
  "image_url": "https://example.com/receipt.png"
}

text is the caption.

Send video ​

http
POST /message/send-video
json
{ "session": "sales", "to": "6281234567890", "video_url": "https://example.com/demo.mp4", "text": "Optional caption" }

Send document ​

http
POST /message/send-document
json
{
  "session": "sales",
  "to": "6281234567890",
  "text": "Invoice for December",
  "document_url": "https://example.com/files/invoice-1042.pdf",
  "document_name": "Invoice-1042.pdf"
}

document_name is the file name the recipient sees and must include the extension. The file type is taken from it (pdf, docx, xlsx, csv, zip, …).

Send audio ​

http
POST /message/send-audio
json
{ "session": "sales", "to": "6281234567890", "audio_url": "https://example.com/hello.ogg", "as_voice_note": true }

With as_voice_note: true the audio is sent as a voice note (push-to-talk). Voice notes play best as OGG/Opus.

Send sticker ​

http
POST /message/send-sticker
json
{ "session": "sales", "to": "6281234567890", "image_url": "https://example.com/sticker.webp" }

Send poll ​

http
POST /message/send-poll
json
{
  "session": "sales",
  "to": "6281234567890",
  "name": "Which delivery slot works best?",
  "options": ["Morning", "Afternoon", "Evening"],
  "selectable_count": 1
}

2 to 12 options. selectable_count is how many options a person may pick (default 1). Votes show up live in the inbox and in the History API.

Deprecated: send text with GET ​

http
GET /message/send-text?session=sales&to=6281234567890&text=Hello&key=wag_your_key

Kept for v4 compatibility. Prefer POST: query strings end up in server and proxy logs, key included.

Uses the unofficial WhatsApp Web protocol. Not affiliated with WhatsApp or Meta.