📱 WhatsApp Bot v1.3

Connect and send messages via WhatsApp Web.js

External API Endpoint: Loading.../api/external/send-message
Use this endpoint to send messages programmatically

Status: Connecting...

Auth ID: Loading...

📖 External API Documentation

Endpoint Information

URL: https://your-app-url.com/api/external/send-message
Method: POST
Content-Type: application/json

Example JSON Request

{
  "number": "60122273341",
  "message": "Hello from API!"
}

Request Parameters

Parameter Type Required Description
number string Yes Phone number with country code (e.g., "60122273341" or "+60122273341")
message string Yes The message text to send

Phone Number & Group JID Formatting

  • Phone Numbers: 60122273341 or +60122273341. The API automatically adds the @s.whatsapp.net suffix.
  • Groups & Communities: Use the Group JID directly (e.g., 120363424584075789@g.us).
  • Newsletters/Channels: Use the Newsletter ID (e.g., 1234567890@newsletter).

Response Formats

Success Response (200)
{
  "success": true,
  "message": "Message sent successfully",
  "messageId": "BAE1234567890ABCDEF",
  "recipient": "60122273341",
  "timestamp": "2024-01-15T10:30:00.000Z"
}
Error Response (400/500)
{
  "error": "WhatsApp client is not ready",
  "details": "Connection not established"
}

Code Examples

cURL
curl -X POST "https://your-app-url.com/api/external/send-message" \
  -H "Content-Type: application/json" \
  -d '{
    "number": "60122273341",
    "message": "Hello from API!"
  }'
JavaScript (Node.js)
const response = await fetch('https://your-app-url.com/api/external/send-message', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    number: '60122273341',
    message: 'Hello from Node.js!'
  })
});

const result = await response.json();
console.log(result);
Python
import requests
import json

url = 'https://your-app-url.com/api/external/send-message'
payload = {
    'number': '60122273341',
    'message': 'Hello from Python!'
}

response = requests.post(url, json=payload)
result = response.json()
print(result)
JavaScript (Browser)
fetch('https://your-app-url.com/api/external/send-message', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    number: '60122273341',
    message: 'Hello from browser!'
  })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

Testing the API

1. Check Status: Visit https://your-app-url.com/api/health

2. Test with cURL:

curl -X POST "https://your-app-url.com/api/external/send-message" \
  -H "Content-Type: application/json" \
  -d '{"number": "YOUR_PHONE_NUMBER", "message": "Test message"}'

3. Verify: Check your WhatsApp to confirm message delivery

Error Codes

Status Code Description
400 Bad Request - Missing required parameters or invalid format
400 WhatsApp client not ready
500 Internal server error - Message sending failed

Rate Limiting & Best Practices

  • Rate Limiting: Implement reasonable delays between requests (1-2 seconds minimum)
  • Error Handling: Always check response status and handle errors gracefully
  • Phone Numbers: Ensure phone numbers include country codes for reliable delivery
  • Message Length: WhatsApp has character limits per message
  • Monitoring: Use the health endpoint to check service availability