Send template messages

Queues an approved WhatsApp template message using the Meta-style payload format. Supports both a single recipient and bulk sending — up to 30,000 contacts in one request, processed asynchronously via a Redis-backed queue.


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".
tostring or array of stringsYesRecipient phone number(s) with country code. Pass a single string for a one-off send, or an array of up to 30,000 numbers to send the same template as a bulk campaign.
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. Applied identically to every recipient in a bulk send.

Bulk sending: When to is an array, all recipients receive the same template.components (i.e. the same variables/media/buttons) — this endpoint does not support per-recipient personalized variables in a single call. For personalized bulk sends, call the endpoint once per recipient/variable-set.


Payload Examples

1. Simple template (single recipient)

{
  "messaging_product": "whatsapp",
  "to": "919912345678",
  "type": "template",
  "template": {
    "name": "welcome_message",
    "language": {
      "code": "en_US"
    }
  }
}

2. Body variables (single recipient)

{
  "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 (single recipient)

{
  "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 (single recipient)

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

5. Bulk send (up to 30,000 contacts)

{
  "messaging_product": "whatsapp",
  "to": [
    "919912345678",
    "919912345679",
    "919912345680"
  ],
  "type": "template",
  "template": {
    "name": "modiinternational",
    "language": {
      "code": "en_US"
    }
  }
}

All numbers in the to array receive the same template + components. For up to 30,000 recipients, the request is accepted immediately and the recipients are pushed onto a Redis-backed queue for processing in the background — you don't need to wait for each individual message to send.


Example Response — 201 Created

Single recipient

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

Bulk send

{
  "success": true,
  "message": "Template campaign queued successfully",
  "request_id": "a1b2c3d4e5f6",
  "username": "demo_user",
  "template_name": "modiinternational",
  "category": "utility",
  "contacts": 30000
}
FieldDescription
successWhether the request was accepted.
messageHuman-readable confirmation.
request_idUnique campaign/request ID — use this to fetch per-contact status via Get Contacts by Request ID.
usernameYour account username.
template_nameName of the template that was queued.
categoryTemplate category (e.g. utility, marketing).
contactsTotal number of recipients queued — returned only for a bulk send.

Confirm exact response field names/shape for bulk sends against production output before publishing — the above reflects the same pattern used elsewhere (e.g. contacts count in the Voice Campaign response) but hasn't been pasted from an actual bulk response yet.


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.
400to is requiredRecipient(s) missing.
400to array cannot exceed 30,000 contactsBulk to array has more than 30,000 numbers.
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.

Add the exact error message for exceeding the 30,000-contact limit once confirmed — placeholder used above.


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.
  • Bulk sending: pass an array in to to send the same template to up to 30,000 contacts in a single request. Recipients are queued via Redis and processed in the background — use the returned request_id with Get Contacts by Request ID to track per-contact status afterward.