Send template messages

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:

MethodExample
HeaderAuthorization: Bearer <jwt_token>
Cookieauth_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

HeaderValue
Content-Typeapplication/json
AuthorizationBearer <jwt_token>

Body Parameters

ParameterTypeRequiredDescription
messaging_productstringYesMust always be "whatsapp".
tostringYesRecipient phone number with country code.
typestringYesMust always be "template".
templateobjectYesTemplate definition.
template.namestringYesExact approved template name from your account.
template.language.codestringYesMeta language code like en_US, or supported language input that can be normalized.
template.componentsarrayNoRequired 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

StatusMessageReason
400Invalid Authorization tokenJWT missing/invalid.
401Route username does not match authenticated userRoute username and JWT username mismatch.
400messaging_product must be whatsappInvalid or missing messaging_product.
400`to is required`Recipient missing.
400type must be templateType is not template.
400template must be an objectTemplate payload missing/invalid.
400template.name is requiredTemplate name missing.
400template.language.code is requiredTemplate language missing/unrecognized.
400template.components must be an arrayInvalid components type.
400Recipient phone number is invalidInvalid number after cleanup.
400Recipient phone number must be between 8 and 20 digitsInvalid number length.
404Template not foundNo matching template for this username.
409Template is pending Meta approvalTemplate exists but not approved yet.
409Template was rejected by MetaTemplate was rejected.
409Template is not approved for sendingTemplate status is not sendable.
422Template language does not match the approved templateLanguage mismatch with stored approved template.
422Template body parameter count does not match the approved templateBody placeholder count mismatch.
422Template header parameter count does not match the approved templateHeader placeholder count mismatch.
500Failed to queue template messageInternal 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 wamid on success.
  • Body and header variable counts are strictly checked against the approved template structure.