WhatsApp API Documentation
A comprehensive REST API for sending messages, media, locations, polls, and managing WhatsApp interactions programmatically with dynamic endpoint URLs.
Base URL
All API endpoints are prefixed with /api/whatsapp after
this base URL. This URL is automatically detected from your current
window location.
Text Message
Send text messages
Photo
Send images (up to 10)
Video
Send videos & GIFs
Audio
Send audio & voice notes
File
Send documents
Location
Send GPS coordinates
Poll
Create polls
Reactions
Add emoji reactions
Introduction
This API allows you to interact with WhatsApp programmatically to send messages, media files, locations, polls, reactions, and perform other messaging operations.
The API uses a RESTful architecture with JSON request/response formats and supports all major WhatsApp features. All endpoints require authentication via an API key passed in the request headers.
Note: This API requires an active WhatsApp session and proper API key authentication. All URLs are dynamically generated based on your current window location.
Authentication
All API requests must include an X-API-Key header
with a valid API key associated with an active WhatsApp session.
Without a valid API key, requests will return a
401 Unauthorized error. You can obtain an API key by
registering your application with the WhatsApp Business API.
Send Text Message
Send a text message to a phone number or WhatsApp group.
Request Headers
| Header | Type | Required | Description |
|---|---|---|---|
| X-API-Key | String | Required | Your API key for authentication |
| Content-Type | String | Required | Must be application/json |
Request Body (JSON)
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | String | Optional* | Recipient phone number (with country code, without '+' or spaces) |
| group | String | Optional* | Group ID for sending to a WhatsApp group |
| message | String | Required | Text message content |
* Either number or group must be
provided
Example Request
Example Response
Send Photo
Send one or multiple images (up to 10) to a phone number or WhatsApp group.
Request Format
This endpoint uses multipart/form-data for file
uploads.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| photos | File[] | Required | Image files (max 10, must be image/*) |
| number | String | Optional* | Recipient phone number |
| group | String | Optional* | Group ID for sending to a group |
| caption | String | Optional | Caption for the image(s) |
| viewOnce | Boolean | Optional | If true, sends as view-once media (default: false) |
* Either number or group must be
provided
Example Request
Example Response
Send Video
Send one or multiple videos (up to 5) to a phone number or WhatsApp group.
Request Format
This endpoint uses multipart/form-data for file
uploads.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| videos | File[] | Required | Video files (max 5, must be video/*) |
| number | String | Optional* | Recipient phone number |
| group | String | Optional* | Group ID for sending to a group |
| caption | String | Optional | Caption for the video(s) |
| gif | Boolean | Optional | If true, sends as GIF (default: false) |
| viewOnce | Boolean | Optional | If true, sends as view-once media (default: false) |
Example Request
Send Audio
Send audio files or voice notes to a phone number or WhatsApp group.
Request Format
This endpoint uses multipart/form-data for file
uploads.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| audios | File[] | Required | Audio files (max 5, must be audio/*) |
| number | String | Optional* | Recipient phone number |
| group | String | Optional* | Group ID for sending to a group |
| voice | Boolean | Optional | If true, sends as WhatsApp voice note (default: false) |
Example Request
Send File
Send documents and files to a phone number or WhatsApp group.
Request Format
This endpoint uses multipart/form-data for file
uploads.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| files | File[] | Required | Files to send (max 5, any type) |
| number | String | Optional* | Recipient phone number |
| group | String | Optional* | Group ID for sending to a group |
| caption | String | Optional | Caption for the file(s) |
Example Request
Send Location
Send a location with latitude and longitude coordinates to a phone number or WhatsApp group.
Request Headers
| Header | Type | Required | Description |
|---|---|---|---|
| X-API-Key | String | Required | Your API key for authentication |
| Content-Type | String | Required | Must be application/json |
Request Body (JSON)
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | String | Optional* | Recipient phone number |
| group | String | Optional* | Group ID for sending to a group |
| location.degreesLatitude | Number | Required | Latitude coordinate (e.g., 40.7128) |
| location.degreesLongitude | Number | Required | Longitude coordinate (e.g., -74.0060) |
* Either number or group must be
provided
Example Request
Send Poll
Create and send a poll to a phone number or WhatsApp group.
Request Headers
| Header | Type | Required | Description |
|---|---|---|---|
| X-API-Key | String | Required | Your API key for authentication |
| Content-Type | String | Required | Must be application/json |
Request Body (JSON)
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | String | Optional* | Recipient phone number |
| group | String | Optional* | Group ID for sending to a group |
| name | String | Required | Poll question/title |
| values | Array | Required | Array of poll options (minimum 2) |
| selectableCount | Number | Optional | Number of options users can select (default: 1) |
| toAnnouncementGroup | Boolean | Optional | For announcement groups (default: false) |
Example Request
Add Reaction NEW
Add an emoji reaction to a specific message.
Request Headers
| Header | Type | Required | Description |
|---|---|---|---|
| X-API-Key | String | Required | Your API key for authentication |
| Content-Type | String | Required | Must be application/json |
Request Body (JSON)
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | String | Optional* | Recipient phone number |
| group | String | Optional* | Group ID for reacting in a group |
| messageKey | String | Required | The message key/ID to react to |
| emoji | String | Optional | Emoji to add (empty string removes reaction) |
Example Request
Delete Message
Delete a specific message for everyone.
Request Headers
| Header | Type | Required | Description |
|---|---|---|---|
| X-API-Key | String | Required | Your API key for authentication |
| Content-Type | String | Required | Must be application/json |
Request Body (JSON)
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | String | Optional* | Recipient phone number |
| group | String | Optional* | Group ID for deleting in a group |
| messageKey | String | Required | The message key/ID to delete |
Example Request
Get Groups
Retrieve a list of all WhatsApp groups for the authenticated session.
Request Headers
| Header | Type | Required | Description |
|---|---|---|---|
| X-API-Key | String | Required | Your API key for authentication |
Example Request
Example Response
Error Handling
The API returns appropriate HTTP status codes and error messages to help you debug issues.
Common Error Codes
| Status Code | Description | Resolution |
|---|---|---|
| 400 | Bad Request | Check required parameters and request format |
| 401 | Unauthorized | Invalid or missing X-API-Key header |
| 404 | Not Found | Session not found with provided API key |
| 413 | Payload Too Large | File size exceeds limits |
| 415 | Unsupported Media Type | Invalid file type for the endpoint |
| 429 | Too Many Requests | Rate limit exceeded, add delays between requests |
| 500 | Internal Server Error | Server error, check error message for details |
Error Response Format
Code Examples
Here are some complete examples using the API with dynamic URLs: