How to Send WhatsApp Messages via API
Sometimes validation isn’t enough — you need to actually send a WhatsApp message: an onboarding text, a notification, a support reply, or a transactional update. The WhatsApp Messaging API lets you do that over plain HTTP: create a session, link a WhatsApp account, then send messages from it.
This guide walks through sending your first message.
How it works
Sending is session-based. A session represents a linked WhatsApp account, so the flow is:
- Create a session — get a session ID and a login QR code.
- Link the account — scan the QR with the WhatsApp account you want to send from.
- Send messages — call the send endpoint with your session ID.
Step 1 — Get an API key
Sign up and copy an active key from your Dashboard. Free credits are included so you can test the flow end to end.
Step 2 — Create a session
curl -X POST "https://api.opendata-api.com/api/project/whatsapp-messaging/create-session?key=YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"mode":"qr","deviceName":"My Bot"}'
The response includes a session ID and the data needed to display a login QR code. Scan it with the WhatsApp account you want to send from — just like linking WhatsApp Web.
Step 3 — Send a message
Once the session is linked, send a text by passing the session ID and a to number (E.164 digits) plus your text:
curl -X POST "https://api.opendata-api.com/api/project/whatsapp-messaging/send-message?key=YOUR_API_KEY&sessionId=SESSION_ID" \
-H "Content-Type: application/json" \
-d '{"to":8613800138000,"text":"Hello from the API!"}'
Beyond text, the same project supports rich media, chats, groups, contacts, presence, and more — see the full operation list on the project page.
Important: use it responsibly
WhatsApp actively polices automated and bulk messaging, and accounts that spam get banned. To stay in good standing:
- Message people who expect it — opted-in users, customers, transactional recipients.
- Don’t blast cold lists. Validate numbers first (see the WhatsApp lookup guide), and only message reachable, consented contacts.
- Respect WhatsApp’s terms and local messaging/privacy laws for your use case.
Try it
Explore the full operation set on the WhatsApp Messaging page, and read the create-session and send-message references. Check pricing for per-request costs.