Queues an approved WhatsApp template message for a recipient using the Meta-style payload format.
Send Template Message
Endpoint
POST https://wa20.nuke.co.in/v6/api/whatsappTemplate/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". |
to | string | Yes | Recipient phone number with country code. |
type | string | Yes | Must always be "template". |
template | object | Yes | Template definition. |
template.name | string | Yes | Exact approved template name from your account. |
template.language.code | string | Yes | Meta language code like en_US, or supported language input that can be normalized. |
template.components | array | No | Required only when template needs variables, media header, or button parameters. |
Payload Examples
1. Simple template
{
"messaging_product": "whatsapp",
"to": "919912345678",
"type": "template",
"template": {
"name": "welcome_message",
"language": {
"code": "en_US"
}
}
}
2. Body variables
{
"messaging_product": "whatsapp",
"to": "919912345678",
"type": "template",
"template": {
"name": "order_confirmation",
"language": {
"code": "en_US"
},
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "Rahul" },
{ "type": "text", "text": "10234" }
]
}
]
}
}
3. Image header + body variable
{
"messaging_product": "whatsapp",
"to": "919912345678",
"type": "template",
"template": {
"name": "promo_banner",
"language": {
"code": "en_US"
},
"components": [
{
"type": "header",
"parameters": [
{
"type": "image",
"image": {
"link": "https://example.com/banner.jpg"
}
}
]
},
{
"type": "body",
"parameters": [
{ "type": "text", "text": "Rahul" }
]
}
]
}
}
4. Dynamic URL button
{
"messaging_product": "whatsapp",
"to": "919912345678",
"type": "template",
"template": {
"name": "order_tracking",
"language": {
"code": "en_US"
},
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "Rahul" }
]
},
{
"type": "button",
"sub_type": "url",
"index": "0",
"parameters": [
{ "type": "text", "text": "10234" }
]
}
]
}
}
Example Response — 201 Created
On success, the template message is queued internally.
{
"success": true,
"message": "Template message queued successfully",
"request_id": "a1b2c3d4e5f6",
"username": "demo_user",
"template_name": "welcome_message",
"category": "utility",
"campaign_id": 123,
"mob_no3_id": 456
}
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. |
400 | messaging_product must be whatsapp | Invalid or missing messaging_product. |
400 | `to is required` | Recipient missing. |
400 | type must be template | Type is not template. |
400 | template must be an object | Template payload missing/invalid. |
400 | template.name is required | Template name missing. |
400 | template.language.code is required | Template language missing/unrecognized. |
400 | template.components must be an array | Invalid components type. |
400 | Recipient phone number is invalid | Invalid number after cleanup. |
400 | Recipient phone number must be between 8 and 20 digits | Invalid number length. |
404 | Template not found | No matching template for this username. |
409 | Template is pending Meta approval | Template exists but not approved yet. |
409 | Template was rejected by Meta | Template was rejected. |
409 | Template is not approved for sending | Template status is not sendable. |
422 | Template language does not match the approved template | Language mismatch with stored approved template. |
422 | Template body parameter count does not match the approved template | Body placeholder count mismatch. |
422 | Template header parameter count does not match the approved template | Header placeholder count mismatch. |
500 | Failed to queue template message | Internal queue/database failure. |
Notes
- This endpoint validates the template against locally stored approved template records before queueing.
- Language inputs such as
en_US, numeric language IDs, or language names may be normalized internally. - The message is queued internally; this endpoint does not directly return provider
wamidon success. - Body and header variable counts are strictly checked against the approved template structure.
