Skip to main content

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 jobId instead of a list of messages. You can track its status using the Bulk Jobs API.

Request Body

FieldTypeRequiredDescription
typeenumYesOne of: TEXT, IMAGE, VIDEO, DOCUMENT.
contentstringYesMessage text (for TEXT) or Caption (for MEDIA).
mediaUrlstringNo*URL of the media file (Required for IMAGE, VIDEO, DOCUMENT).
recipientsarrayNo*Array of phone numbers in E.164 format (e.g. "919999999999").
groupIdsarrayNo*Array of Group IDs to send to.
captionstringNoCaption for media messages.
scheduledAtstringNoISO 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

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();

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"
}