Appearance
Sending Messages
This guide explains how to send different types of WhatsApp messages using the WhatsGate API.
Prerequisites
Before you can send messages, you need to:
- Create an API token for authentication
- Link a WhatsApp device to send messages from
Message Types
The WhatsGate API supports sending the following types of messages:
- Text messages
- Image messages
- Video messages
- Audio messages
- File/document messages
- Location messages
Sending Text Messages
To send a text message, make a POST request to the /send/text
endpoint:
bash
curl -X POST \
https://{subdomain}.whatsgate.net/api/send/text \
-H 'Access-Token: your_api_token_here' \
-H 'Content-Type: application/json' \
-d '{
"sender_device": "123456789",
"phone": "987654321",
"message": "Hello, this is a test message"
}'
Parameters
sender_device
: The mobile number of the device you want to send the message fromphone
: The recipient's phone numbermessage
: The text message (max 4000 characters)
Sending Image Messages
To send an image message, make a POST request to the /send/image
endpoint:
bash
curl -X POST \
https://{subdomain}.whatsgate.net/api/send/image \
-H 'Access-Token: your_api_token_here' \
-H 'Content-Type: application/json' \
-d '{
"sender_device": "123456789",
"phone": "987654321",
"media": "https://example.com/image.jpg",
"caption": "Check out this image"
}'
Parameters
sender_device
: The mobile number of the device you want to send the message fromphone
: The recipient's phone numbermedia
: URL or base64 encoded image datacaption
(optional): A caption for the image (max 4000 characters)
Sending Video Messages
To send a video message, make a POST request to the /send/video
endpoint:
bash
curl -X POST \
https://{subdomain}.whatsgate.net/api/send/video \
-H 'Access-Token: your_api_token_here' \
-H 'Content-Type: application/json' \
-d '{
"sender_device": "123456789",
"phone": "987654321",
"media": "https://example.com/video.mp4",
"caption": "Check out this video"
}'
Parameters
sender_device
: The mobile number of the device you want to send the message fromphone
: The recipient's phone numbermedia
: URL of the video filecaption
(optional): A caption for the video (max 4000 characters)
Sending Audio Messages
To send an audio message, make a POST request to the /send/audio
endpoint:
bash
curl -X POST \
https://{subdomain}.whatsgate.net/api/send/audio \
-H 'Access-Token: your_api_token_here' \
-H 'Content-Type: application/json' \
-d '{
"sender_device": "123456789",
"phone": "987654321",
"media": "https://example.com/audio.mp3"
}'
Parameters
sender_device
: The mobile number of the device you want to send the message fromphone
: The recipient's phone numbermedia
: URL of the audio file
Sending File/Document Messages
To send a file or document, make a POST request to the /send/file
endpoint:
bash
curl -X POST \
https://{subdomain}.whatsgate.net/api/send/file \
-H 'Access-Token: your_api_token_here' \
-H 'Content-Type: application/json' \
-d '{
"sender_device": "123456789",
"phone": "987654321",
"media": "https://example.com/document.pdf",
"caption": "Important document"
}'
Parameters
sender_device
: The mobile number of the device you want to send the message fromphone
: The recipient's phone numbermedia
: URL of the file to sendcaption
(optional): A caption for the file (max 4000 characters)
Sending Location Messages
To send a location message, make a POST request to the /send/location
endpoint:
bash
curl -X POST \
https://{subdomain}.whatsgate.net/api/send/location \
-H 'Access-Token: your_api_token_here' \
-H 'Content-Type: application/json' \
-d '{
"sender_device": "123456789",
"phone": "987654321",
"lat": 37.7749,
"lng": -122.4194
}'
Parameters
sender_device
: The mobile number of the device you want to send the message fromphone
: The recipient's phone numberlat
: Latitude coordinatelng
: Longitude coordinate
Phone Number Format
When specifying phone numbers, use the following format:
- Include the country code without the '+' or '00' prefix
- Do not include any spaces or special characters
- Example: For a US number +1 (555) 123-4567, use "15551234567"
Error Handling
If there's an error with your request, you'll receive a response with a success
field set to false
and a message
field describing the error:
json
{
"success": false,
"message": "Error message"
}
Common error messages include:
- "The selected sender device is invalid."
- "The phone field is required."
- "The media field is required."
- "The media must be a valid URL."
- "The message field is required."
- "The message may not be greater than 4000 characters."