Send Message
Send text or media messages to individual contacts or groups.
Endpoint: POST /messages/send
Bulk Messaging Limit
[!NOTE] If you send a message to more than 10 recipients at once, it will be automatically processed as a Bulk Message Job. The response will return a
jobIdinstead of a list of messages. You can track its status using the Bulk Jobs API.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
type | enum | Yes | One of: TEXT, IMAGE, VIDEO, DOCUMENT. |
content | string | Yes | Message text (for TEXT) or Caption (for MEDIA). |
mediaUrl | string | No* | URL of the media file (Required for IMAGE, VIDEO, DOCUMENT). |
recipients | array | No* | Array of phone numbers in E.164 format (e.g. "919999999999"). |
groupIds | array | No* | Array of Group IDs to send to. |
caption | string | No | Caption for media messages. |
scheduledAt | string | No | ISO 8601 date string (e.g. 2023-12-25T10:00:00Z) to schedule the message. |
* At least one of recipients or groupIds must be provided.
Code Examples
- Node.js
- Scheduled (Node.js)
- Python
const axios = require('axios');
const sendText = async () => {
try {
const response = await axios.post('https://api.whatsspot.in/messages/send', {
type: 'TEXT',
content: 'Hello! Your appointment is confirmed.',
recipients: ['919999999999']
}, {
headers: { 'x-api-key': 'YOUR_API_TOKEN' }
});
console.log(response.data);
} catch (error) {
console.error(error.response.data);
}
};
sendText();
const axios = require('axios');
const scheduleMessage = async () => {
try {
const response = await axios.post('https://api.whatsspot.in/messages/send', {
type: 'TEXT',
content: 'Happy New Year!',
recipients: ['919999999999'],
scheduledAt: '2024-01-01T00:00:00Z'
}, {
headers: { 'x-api-key': 'YOUR_API_TOKEN' }
});
console.log(response.data);
} catch (error) {
console.error(error.response.data);
}
};
scheduleMessage();
import requests
url = "https://api.whatsspot.in/messages/send"
payload = {
"type": "IMAGE",
"mediaUrl": "https://example.com/invoice.pdf",
"caption": "Here is your invoice",
"content": "Here is your invoice", # content is used as caption for media
"recipients": ["919999999999"]
}
headers = {
"x-api-key": "YOUR_API_TOKEN",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
Response (Single)
{
"success": true,
"message": {
"id": "msg_123...",
"status": "SENT",
"sentAt": "2023-10-27T10:00:00Z"
},
"async": false
}
Response (Bulk Job)
Returned when recipients > 10 or sending to groups.
{
"success": true,
"jobId": "job_abc123...",
"status": "PROCESSING",
"message": "Bulk job created with 50 recipients"
}