Developer Documentation

WhatsApp API Reference

Complete reference for the WhatsApp Messaging REST API. Covers authentication, all endpoints, code examples in cURL, Python, and JavaScript, error handling, and rate limits.

Getting Started

From zero to your first WhatsApp message in under 5 minutes.

  1. 1
    Subscribe on RapidAPI
    Head to the RapidAPI listing and subscribe to the free Basic plan (no credit card required). You'll receive an x-rapidapi-key header value.
  2. 2
    Create a Session
    Call POST /v1/sessions with a name for your session. A session represents one WhatsApp account.
  3. 3
    Authenticate via QR Code
    Fetch the QR code image from GET /v1/{session}/auth/qr and scan it with WhatsApp on your phone.
  4. 4
    Send Your First Message
    Call POST /v1/sendText with a chatId (phone number), text, and session name.

Authentication

All requests require two headers provided by RapidAPI.

HeaderValueRequired
x-rapidapi-keyYour RapidAPI keyYes
x-rapidapi-hostwhatsapp-messaging-bot.p.rapidapi.comYes
Content-Typeapplication/jsonFor POST/PUT/PATCH
💡Your API key is available on the RapidAPI dashboard after subscribing. Never expose it in client-side code — always call the API from your server.

Base URL & Versioning

https://whatsapp-messaging-bot.p.rapidapi.com/v1

All endpoints are prefixed with /v1. The current stable API version is v1. Breaking changes will result in a new version prefix (/v2).

Sessions

A session = one authenticated WhatsApp account. You must create and authenticate a session before sending messages.

MethodPathDescription
GET/v1/sessionsList all sessions
POST/v1/sessionsCreate a new session
GET/v1/sessions/{session}Get session details
DELETE/v1/sessions/{session}Delete a session
POST/v1/sessions/startStart a session
POST/v1/sessions/stopStop a session
GET/v1/{session}/auth/qrGet QR code image for authentication
GET/v1/{session}/auth/pairing-codeRequest pairing code (phone number auth)
POST/v1/sessions/logoutLog out the session

Create Session

create_session.sh
curl -X POST "https://whatsapp-messaging-bot.p.rapidapi.com/v1/sessions" \
  -H "x-rapidapi-key: YOUR_API_KEY" \
  -H "x-rapidapi-host: whatsapp-messaging-bot.p.rapidapi.com" \
  -H "Content-Type: application/json"

Get QR Code

get_qr.sh
curl -G "https://whatsapp-messaging-bot.p.rapidapi.com/v1/{session}/auth/qr" \
  -H "x-rapidapi-key: YOUR_API_KEY" \
  -H "x-rapidapi-host: whatsapp-messaging-bot.p.rapidapi.com" \
  --data-urlencode "format=binary"
# Returns a PNG image you can display for scanning

Webhooks

Receive real-time events from a WhatsApp session via HTTP POST to your server.

MethodPathDescription
POST/v1/sessions/{session}/webhooksRegister a webhook URL for a session
DELETE/v1/sessions/{session}/webhooksRemove a registered webhook URL

Register a Webhook

add_webhook.sh
curl -X POST "https://whatsapp-messaging-bot.p.rapidapi.com/v1/sessions/{session}/webhooks"   -H "x-rapidapi-key: YOUR_API_KEY"   -H "x-rapidapi-host: whatsapp-messaging-bot.p.rapidapi.com"   -H "Content-Type: application/json"   -d '{
    "webhookUrl": "https://your-server.com/webhook",
    "events": ["message", "session.status"]
  }'

Request body fields

  • webhookUrl (required) — The HTTPS URL that will receive POST requests for each event.
  • events — Array of event names to subscribe to. Defaults to ["message"] if omitted.
  • hmacKey — Optional secret key. When set, each request includes an X-Webhook-Hmac signature header for verification.
  • retries — Optional retry config: { policy: "exponential", delaySeconds: 2, attempts: 5 }
  • customHeaders — Optional array of { name, value } headers added to every webhook request (e.g. for token auth).

Supported events values

EventDescription
session.statusSession state changes: STARTING, SCAN_QR_CODE, AUTHENTICATED, STOPPED, FAILED
messageNew incoming messages only
message.anyAll messages — both incoming and outgoing
message.reactionReactions added to messages
message.ackMessage delivery and read acknowledgements
message.waitingWaiting for message delivery confirmation
message.revokedMessages that were deleted or recalled
message.editedMessages that were edited after sending
chat.archiveChat archived or unarchived
group.v2.joinJoined a group (new API)
group.v2.leaveLeft a group (new API)
group.v2.updateGroup settings updated (new API)
group.v2.participantsParticipant added or removed (new API)
group.joinJoined a group (legacy)
group.leaveLeft a group (legacy)
presence.updateContact's online/offline/typing status changed
poll.voteA vote was cast on a poll
poll.vote.failedA poll vote attempt failed
call.receivedIncoming call received
call.acceptedCall was accepted
call.rejectedCall was rejected
label.upsertLabel created or updated
label.deletedLabel deleted
label.chat.addedLabel applied to a chat
label.chat.deletedLabel removed from a chat
event.responseEvent response received
event.response.failedEvent response failed
engine.eventInternal engine-level event

Messages

Send any WhatsApp message type to contacts, groups, or channels.

MethodPathDescription
POST/v1/sendTextSend a text message
POST/v1/sendImageSend an image with optional caption
POST/v1/sendFileSend any file (PDF, DOCX, etc.)
POST/v1/sendVideoSend a video message
POST/v1/sendVoiceSend a voice note
POST/v1/sendLocationSend a location pin
POST/v1/sendContactVcardShare a contact card
POST/v1/sendPollSend a poll
POST/v1/replyReply to a message
POST/v1/sendSeenMark message as read
POST/v1/startTypingStart typing indicator
POST/v1/stopTypingStop typing indicator

Send Text Message

send_text.py
curl -X POST "https://whatsapp-messaging-bot.p.rapidapi.com/v1/sendText" \
  -H "x-rapidapi-key: YOUR_API_KEY" \
  -H "x-rapidapi-host: whatsapp-messaging-bot.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{
    "chatId": "1234567890",
    "text": "Check this out: https://example.com",
    "session": "default",
    "linkPreview": true,
    "linkPreviewHighQuality": true
  }'

Send Image

send_image.sh
curl -X POST "https://whatsapp-messaging-bot.p.rapidapi.com/v1/sendImage" \
  -H "x-rapidapi-key: YOUR_API_KEY" \
  -H "x-rapidapi-host: whatsapp-messaging-bot.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{
    "chatId": "1234567890",
    "session": "default",
    "file": {
      "url": "https://example.com/photo.jpg",
      "mimetype": "image/jpeg"
    },
    "caption": "Check this out!"
  }'

chatId Formats

TypechatId ExampleNotes
Individual1234567890Phone number only — country code auto-detected
Group120363024802736123@g.usObtain from GET /v1/sessions/{session}/groups
Channel120363024802736123@s.whatsapp.netObtain from channel search endpoint

Link Preview Support (sendText)

The /v1/sendText endpoint supports automatic link preview generation:

  • linkPreview (boolean, optional): Set to true to enable link preview for any URLs in your message text.
  • linkPreviewHighQuality (boolean, optional): Set to true to enable high-quality link previews (requires additional upload to WhatsApp servers).

Example: Sending a message with URL "Check this: https://example.com" with linkPreview: true will generate and display a preview card in WhatsApp.

Groups

Create, manage, and configure WhatsApp Groups via API.

MethodPathDescription
GET/v1/sessions/{session}/groupsList all groups
POST/v1/sessions/{session}/groupsCreate a new group
GET/v1/sessions/{session}/groups/{groupId}Get group details
DELETE/v1/sessions/{session}/groups/{groupId}Delete a group
POST/v1/sessions/{session}/groups/{groupId}/leaveLeave a group
PUT/v1/sessions/{session}/groups/{groupId}/subjectUpdate group name
PUT/v1/sessions/{session}/groups/{groupId}/descriptionUpdate group description
POST/v1/sessions/{session}/groups/{groupId}/participants/addAdd participants
POST/v1/sessions/{session}/groups/{groupId}/participants/removeRemove participants
POST/v1/sessions/{session}/groups/{groupId}/admin/promotePromote to admin
POST/v1/sessions/{session}/groups/{groupId}/admin/demoteDemote from admin

Create Group

create_group.sh
curl -X POST "https://whatsapp-messaging-bot.p.rapidapi.com/v1/sessions/{session}/groups" \
  -H "x-rapidapi-key: YOUR_API_KEY" \
  -H "x-rapidapi-host: whatsapp-messaging-bot.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Team",
    "participants": [
      {"id": "1234567890@c.us"},
      {"id": "9876543210@c.us"}
    ]
  }'

Channels

Broadcast to unlimited subscribers with WhatsApp Channels (broadcast-only).

MethodPathDescription
GET/v1/sessions/{session}/channelsList subscribed channels
POST/v1/sessions/{session}/channelsCreate a channel
GET/v1/sessions/{session}/channels/{channelId}Get channel details
DELETE/v1/sessions/{session}/channels/{channelId}Delete a channel
GET/v1/sessions/{session}/channels/{channelId}/messages/previewGet channel preview messages

Contacts

Check WhatsApp registration status.

MethodPathDescription
GET/v1/contacts/check-exists?phone={phone}&session={session}Check if phone number is on WhatsApp
â„šī¸Use the check-exists endpoint before messaging to avoid sending to non-WhatsApp numbers, which saves quota.

Presence

Set typing indicators, read receipts, and online status.

MethodPathDescription
POST/v1/sessions/{session}/presenceSet session presence (online/offline/typing/recording/paused)
GET/v1/sessions/{session}/presenceGet all chats presence
POST/v1/startTypingStart typing indicator in a chat
POST/v1/stopTypingStop typing indicator in a chat
POST/v1/sendSeenMark messages as read

Error Handling

All errors return a consistent JSON body.

errors.json
// All errors follow this shape:
{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "chatId is required"
}

// HTTP status codes used:
// 400 Bad Request      — invalid or missing parameters
// 401 Unauthorized     — missing or invalid API key
// 404 Not Found        — session or resource not found
// 409 Conflict         — session already exists
// 429 Too Many Reqs    — rate limit exceeded
// 500 Internal Error   — server-side error (retry)
HTTP CodeMeaningRecommendation
400Bad RequestFix request body / query params
401UnauthorizedCheck your x-rapidapi-key
404Not FoundVerify session name / resource ID
409ConflictSession name already exists — use a different name
429Too Many RequestsImplement exponential backoff; upgrade plan
500Internal Server ErrorRetry with backoff; contact support if persistent

Rate Limits

Limits apply per API key per plan.

PlanRequests / MonthReq / SecondSessions
Basic (Free)100101
Pro1,000103
Ultra10,0002010
Mega50,00025Unlimited
âš ī¸When you hit the rate limit you receive a 429 Too Many Requests response. Implement exponential backoff starting at 1 second.

OpenAPI / Swagger

Full OpenAPI 3.0 specification — browse, search, and test every endpoint interactively.

{ }

Interactive API Reference

Browse every endpoint, view request/response schemas, and use the live Try-it-out panel — all powered by the bundled OpenAPI 3.0 spec.

SessionsMessagesGroupsChannelsContactsPresence

The raw spec file is also available for download or import into Postman, Insomnia, or any OpenAPI-compatible toolchain:

FAQ

Do I need a WhatsApp Business account?

No. You just need a regular WhatsApp account on a phone number. Authenticate via QR code or pairing code through the API.

Can I run multiple WhatsApp numbers simultaneously?

Yes. Create one session per number. Basic allows 1 session, Pro allows 3, Ultra allows 10, and Mega is unlimited.

What happens if I exceed my monthly quota?

On the Basic plan, requests are hard-blocked once you hit 100/month. On Pro, Ultra, and Mega, overage billing kicks in automatically at the per-request rate shown in your plan.

Is there an SDK?

The API is a standard REST API — any HTTP library works. RapidAPI auto-generates code snippets for 30+ languages including Python, JavaScript, PHP, Ruby, Go, and more.

Does the API support webhooks / incoming messages?

Yes. POST to /v1/sessions/{session}/webhooks with a webhookUrl and an events array. The events field defaults to ["message"] if omitted. You can subscribe to 29 event types including message, message.any, message.reaction, session.status, presence.update, group.v2.join, call.received, and more. See the Webhooks section above for the full list.

Still have questions?

Contact Support