Templates API's

This section documents the three endpoints used to create, list whatsApp message templates.

1. Create Template

Creates a new message template for the authenticated user and queues it for approval.

Endpoint

POST https://wa20.nuke.co.in/webhook/api/createTemplates.php

Authentication

Required. Send a JWT in one of the following ways:

MethodExample
HeaderAuthorization: Bearer <jwt_token>
Cookieauth_token=<jwt_token>

The token payload must contain data.name or data.username — this becomes the template owner.

Headers

HeaderValue
Content-Typeapplication/json

Body Parameters

ParameterTypeRequiredDescription
template_namestringYesUnique name for the template (per user).
categorystringYesOne of marketing, utility, auth.
languageintegerNoLanguage ID (see table below). Defaults to 1 (English (US)) if omitted or invalid.
header_area_typestringNoOne of media, text, none. Defaults to none.
header_media_typestringConditionalRequired when header_area_type is media. One of Image, Document, Video.
template_bodystringNoMain body text of the template.
template_footerstringNoFooter text of the template.
quick_reply_buttonsarrayNoArray of button objects, each { "type": "QUICK_REPLY", "text": "..." }.

Supported Language IDs

IDLanguageShort Code
1English (US)en_US
2Telugute
3Tamilta
4Russianru
5Punjabipa
6Marathimr
7Malayalamml
8Hindihi
9Gujaratigu
10Urduur
11Bengalibn
12Kannadakn
13English (UK)en_GB
14Englishen
15Hebrewhe

Pass the numeric id as the language field in the request body. If you omit it or pass an invalid ID, it defaults to 1 (en_US).

Example Request

POST https://wa20.nuke.co.in/webhook/api/createTemplates.php
Authorization: Bearer eyJhbGciOi...
Content-Type: application/json

{
  "template_name": "order_confirmation",
  "category": "utility",
  "language": 1,
  "header_area_type": "text",
  "template_body": "Hi {{1}}, your order #{{2}} has been confirmed.",
  "template_footer": "Thank you for shopping with us.",
  "quick_reply_buttons": [
    { "type": "QUICK_REPLY", "text": "Track Order" },
    { "type": "QUICK_REPLY", "text": "Contact Support" }
  ]
}

cURL Example

curl -X POST "https://wa20.nuke.co.in/webhook/api/createTemplates.php" \
  -H "Authorization: Bearer eyJhbGciOi..." \
  -H "Content-Type: application/json" \
  -d '{
    "template_name": "order_confirmation",
    "category": "utility",
    "language": 1,
    "header_area_type": "text",
    "template_body": "Hi {{1}}, your order #{{2}} has been confirmed.",
    "template_footer": "Thank you for shopping with us.",
    "quick_reply_buttons": [
      { "type": "QUICK_REPLY", "text": "Track Order" },
      { "type": "QUICK_REPLY", "text": "Contact Support" }
    ]
  }'

Example Response — 200 OK

{
  "success": true,
  "message": "Template created successfully",
  "username": "shubham",
  "template_id": 214,
  "template_controller_id": 214,
  "status": 3,
  "controller_status": "pending",
  "language_id": 1,
  "language": "English (US)"
}

Error Responses

StatusMessageReason
405Method not allowedRequest method is not POST.
401Invalid Authorization tokenMissing or unparseable JWT / no username claim.
400template_name is requiredtemplate_name missing or empty.
400category must be marketing, utility, or authInvalid category value.
400header_area_type must be media, text, or noneInvalid header_area_type value.
400header_media_type must be Image, Document, or Video when header_area_type is mediaMissing/invalid header_media_type for a media header.
400quick_reply_buttons must be an arrayquick_reply_buttons not an array.
400Each quick reply button must contain type=QUICK_REPLY and a non-empty textMalformed button object.
409This template name is already existA template with this name already exists for the user.
500Database connection failed / insert errorsServer/database error.

Notes

  • New templates are always created with status = 3 (pending review).
  • A matching row is also created in the internal template controller/queue, with type set to custom, customutility, or customauth depending on category.

2. Get Templates by Username

Returns all templates belonging to a given username.

Endpoint

GET https://wa20.nuke.co.in/webhook/api/templates.php?username={username}

Authentication

None enforced at this endpoint — access is controlled purely by the username query parameter, so treat it as an internal/admin endpoint rather than a client-facing one until authentication is added.

Query Parameters

ParameterTypeRequiredDescription
usernamestringYesUsername to fetch templates for.

Example Request

GET https://wa20.nuke.co.in/webhook/api/templates.php?username=username

cURL Example

curl -X GET "https://wa20.nuke.co.in/webhook/api/templates.php?username=username"

Example Response — 200 OK

[
  {
    "id": 214,
    "username": "shubham",
    "template_name": "order_confirmation",
    "status": 3,
    "category": 2,
    "language": 1,
    "header_area_type": "text",
    "header_media_type": "",
    "template_body": "Hi {{1}}, your order #{{2}} has been confirmed.",
    "template_footer": "Thank you for shopping with us.",
    "quick_replies": "[{\"type\":\"QUICK_REPLY\",\"text\":\"Track Order\"}]",
    "created_at": "2026-07-11 10:15:32"
  }
]

Error Responses

StatusMessageReason
400username is requiredMissing or empty username parameter.
404Template not found for this usernameNo templates exist for this username.
500Database connection failed / Failed to prepare queryServer/database error.