Sends a WhatsApp message to a recipient using the configured WhatsApp account for the authenticated user. Supports text, media, location, contacts, interactive, reaction, and template payloads in Meta-style format.
Send Session Message
Endpoint
POST https://wa20.nuke.co.in/v6/api/whatsapp/24/{{username}}/messages
Replace {{username}} in the URL with your account username.
Authentication
Required. Send a JWT in one of these ways:
| Method | Example |
|---|---|
| Header | Authorization: Bearer <jwt_token> |
| Cookie | auth_token=<jwt_token> |
The {{username}} in the URL must match the username inside your JWT. If they don't match, the request is rejected with 401 Route username does not match authenticated user.
Headers
| Header | Value |
|---|---|
Content-Type | application/json |
Authorization | Bearer <jwt_token> |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
messaging_product | string | Yes | Must always be "whatsapp". |
recipient_type | string | No | Defaults to "individual". |
to | string | Yes | Recipient phone number with country code. +, spaces, and dashes are cleaned automatically. |
type | string | Yes | Message type. Supported: text, image, audio, video, document, sticker, location, contacts, interactive, reaction, template. |
text | object | Conditionally | Required when type = "text". |
image | object | Conditionally | Required when type = "image". Must contain id or link. |
audio | object | Conditionally | Required when type = "audio". Must contain id or link. |
video | object | Conditionally | Required when type = "video". Must contain id or link. |
document | object | Conditionally | Required when type = "document". Must contain id or link. |
sticker | object | Conditionally | Required when type = "sticker". Must contain id or link. |
location | object | Conditionally | Required when type = "location". Must contain latitude and longitude. |
contacts | array | Conditionally | Required when type = "contacts". Must be a non-empty array. |
interactive | object | Conditionally | Required when type = "interactive". |
reaction | object | Conditionally | Required when type = "reaction". Must contain message_id and emoji. |
template | object | Conditionally | Required when type = "template". If used here, the request is internally handled by the template-message flow. |
Payload Examples
1. Text message
{
"messaging_product": "whatsapp",
"to": "919912345678",
"type": "text",
"text": {
"body": "Hello Rahul"
}
}
2. Image message
{
"messaging_product": "whatsapp",
"to": "919912345678",
"type": "image",
"image": {
"link": "https://example.com/sample.jpg"
}
}
3. Document message
{
"messaging_product": "whatsapp",
"to": "919912345678",
"type": "document",
"document": {
"link": "https://example.com/invoice.pdf"
}
}
4. Location message
{
"messaging_product": "whatsapp",
"to": "919912345678",
"type": "location",
"location": {
"latitude": 28.6139,
"longitude": 77.2090,
"name": "New Delhi",
"address": "Delhi, India"
}
}
5. Reaction message
{
"messaging_product": "whatsapp",
"to": "919912345678",
"type": "reaction",
"reaction": {
"message_id": "wamid.HBgM...",
"emoji": "👍"
}
}
6. Interactive message
{
"messaging_product": "whatsapp",
"to": "919912345678",
"type": "interactive",
"interactive": {
"type": "button",
"body": {
"text": "Choose an option"
},
"action": {
"buttons": [
{
"type": "reply",
"reply": {
"id": "yes",
"title": "Yes"
}
}
]
}
}
}
Example Response — 200 OK
On success, the provider response is passed through directly.
{
"messaging_product": "whatsapp",
"contacts": [
{
"input": "919912345678",
"wa_id": "919912345678"
}
],
"messages": [
{
"id": "wamid.HBgM..."
}
]
}
Error Responses
| Status | Message | Reason |
|---|---|---|
400 | Invalid Authorization token | JWT missing/invalid. |
401 | Route username does not match authenticated user | Route username and JWT username mismatch. |
404 | No WhatsApp account found for this username | No WhatsApp account mapped to this username. |
400 | messaging_product must be whatsapp | Invalid or missing messaging_product. |
400 | `to is required` | Recipient missing. |
400 | `type is required` | Message type missing. |
400 | Recipient phone number is invalid | Number invalid after cleanup. |
400 | Recipient phone number must be between 8 and 20 digits | Number length invalid. |
400 | `text.body is required` | Missing text body for text message. |
400 | `image is required` | Image object missing. |
400 | `image.id or image.link is required` | Image source missing. |
400 | `audio.id or audio.link is required` | Audio source missing. |
400 | `video.id or video.link is required` | Video source missing. |
400 | `document.id or document.link is required` | Document source missing. |
400 | `sticker.id or sticker.link is required` | Sticker source missing. |
400 | `location.latitude and location.longitude are required` | Location coordinates missing. |
400 | `contacts must be a non-empty array` | Contacts payload invalid. |
400 | `interactive is required` | Interactive payload missing. |
400 | `reaction.message_id and reaction.emoji are required` | Reaction payload invalid. |
404 | Missing phone-number ID for this WhatsApp account | Account config incomplete. |
404 | Missing account token for this WhatsApp account | Provider token missing. |
500 | Unable to resolve provider endpoint | Could not build provider API endpoint. |
502 | (provider error message) | Provider rejected the request or returned an error. |
Notes
- Phone numbers are normalized before sending.
- For non-template messages, the request is sent directly to the provider.
- If
type = "template"is sent on this endpoint, it is internally redirected to template-message handling.
