> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# WhatsApp message templates

> Create and manage the Meta-approved templates required to start WhatsApp conversations.

Templates are pre-approved message formats required when reaching out to customers who have not
contacted you first. Think of them as pre-written scripts that Meta reviews and approves in advance.
Once approved, you can send them to any customer at any time. See
[Send a template message](/docs/platform/messaging/whatsapp/send-messages#template-message) for how to
deliver one.

WhatsApp on SignalWire is in **early-access alpha**. Template management through the SignalWire
Dashboard is planned; today, templates are managed via the API or directly in the Meta Business
dashboard.

## Template components

A template is made up of components. A **Body** component is required; the header, footer, and
buttons are optional.

| Component | Description                                                                          |
| --------- | ------------------------------------------------------------------------------------ |
| `HEADER`  | Optional title line. Can be plain text or media (image, video, document).            |
| `BODY`    | **Required.** Main message text. Supports variable placeholders for personalization. |
| `FOOTER`  | Optional closing line (e.g. "Thank you for your order").                             |
| `BUTTONS` | Optional interactive buttons: quick reply, phone number, or URL.                     |

### Parameters

Templates support variable placeholders so you can personalize messages with customer names, order
numbers, and so on. There are two styles, set by `parameter_format`:

* **Positional** (`positional`): referenced as `{{1}}`, `{{2}}`, `{{3}}` in order.
* **Named** (`named`): referenced by descriptive labels like `{{first_name}}` or `{{order_status}}`.

### Categories

The `category` field must be one of:

* `marketing`: promotional messages, offers, announcements
* `utility`: transactional messages, order updates, account alerts
* `authentication`: one-time passwords and verification codes

## Manage templates

Templates are managed through the API. For the full request and response schemas, see the reference:

#### [Create a template](/docs/apis/rest/whatsapp/create-whatsapp-template)

#### [List templates](/docs/apis/rest/whatsapp/list-whatsapp-templates)

#### [Get a template](/docs/apis/rest/whatsapp/retrieve-whatsapp-template)

#### [Update a template](/docs/apis/rest/whatsapp/update-whatsapp-template)

#### [Delete a template](/docs/apis/rest/whatsapp/delete-whatsapp-template)

The example below creates an order-update template with positional parameters. The `components`
array is the heart of the request; each component's fields depend on its `type`.

### Request

POST https\://%7BYour\_Space\_Name%7D.signalwire.com/api/messaging/whatsapp/templates

```curl
curl -X POST https://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates \
     -H "Content-Type: application/json" \
     -u "<project_id>:<api_token>" \
     -d '{
  "whatsapp_business_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "name": "order_update",
  "language": "en_US",
  "category": "utility",
  "parameter_format": "positional",
  "components": [
    {
      "type": "HEADER",
      "example": {
        "header_text": [
          "Jane Smith"
        ]
      },
      "format": "TEXT",
      "text": "Order Update for {{1}}"
    },
    {
      "type": "BODY",
      "example": {
        "body_text": [
          [
            "ORD-9821",
            "out for delivery"
          ]
        ]
      },
      "text": "Your order {{1}} is currently {{2}}."
    },
    {
      "type": "FOOTER",
      "text": "Thank you for shopping with us."
    },
    {
      "type": "BUTTONS",
      "buttons": [
        {
          "text": "Track Order",
          "type": "QUICK_REPLY"
        },
        {
          "text": "Contact Support",
          "type": "URL",
          "url": "https://example.com/support"
        }
      ]
    }
  ]
}'
```

```python
import requests

url = "https://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates"

payload = {
    "whatsapp_business_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "name": "order_update",
    "language": "en_US",
    "category": "utility",
    "parameter_format": "positional",
    "components": [
        {
            "type": "HEADER",
            "example": { "header_text": ["Jane Smith"] },
            "format": "TEXT",
            "text": "Order Update for {{1}}"
        },
        {
            "type": "BODY",
            "example": { "body_text": [["ORD-9821", "out for delivery"]] },
            "text": "Your order {{1}} is currently {{2}}."
        },
        {
            "type": "FOOTER",
            "text": "Thank you for shopping with us."
        },
        {
            "type": "BUTTONS",
            "buttons": [
                {
                    "text": "Track Order",
                    "type": "QUICK_REPLY"
                },
                {
                    "text": "Contact Support",
                    "type": "URL",
                    "url": "https://example.com/support"
                }
            ]
        }
    ]
}
headers = {
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers, auth=("<project_id>", "<api_token>"))

print(response.json())
```

```javascript
const url = 'https://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates';
const credentials = btoa("<project_id>:<api_token>");

const options = {
  method: 'POST',
  headers: {
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/json'
  },
  body: '{"whatsapp_business_id":"3fa85f64-5717-4562-b3fc-2c963f66afa6","name":"order_update","language":"en_US","category":"utility","parameter_format":"positional","components":[{"type":"HEADER","example":{"header_text":["Jane Smith"]},"format":"TEXT","text":"Order Update for {{1}}"},{"type":"BODY","example":{"body_text":[["ORD-9821","out for delivery"]]},"text":"Your order {{1}} is currently {{2}}."},{"type":"FOOTER","text":"Thank you for shopping with us."},{"type":"BUTTONS","buttons":[{"text":"Track Order","type":"QUICK_REPLY"},{"text":"Contact Support","type":"URL","url":"https://example.com/support"}]}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates"

	payload := strings.NewReader("{\n  \"whatsapp_business_id\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n  \"name\": \"order_update\",\n  \"language\": \"en_US\",\n  \"category\": \"utility\",\n  \"parameter_format\": \"positional\",\n  \"components\": [\n    {\n      \"type\": \"HEADER\",\n      \"example\": {\n        \"header_text\": [\n          \"Jane Smith\"\n        ]\n      },\n      \"format\": \"TEXT\",\n      \"text\": \"Order Update for {{1}}\"\n    },\n    {\n      \"type\": \"BODY\",\n      \"example\": {\n        \"body_text\": [\n          [\n            \"ORD-9821\",\n            \"out for delivery\"\n          ]\n        ]\n      },\n      \"text\": \"Your order {{1}} is currently {{2}}.\"\n    },\n    {\n      \"type\": \"FOOTER\",\n      \"text\": \"Thank you for shopping with us.\"\n    },\n    {\n      \"type\": \"BUTTONS\",\n      \"buttons\": [\n        {\n          \"text\": \"Track Order\",\n          \"type\": \"QUICK_REPLY\"\n        },\n        {\n          \"text\": \"Contact Support\",\n          \"type\": \"URL\",\n          \"url\": \"https://example.com/support\"\n        }\n      ]\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.SetBasicAuth("<project_id>", "<api_token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request.basic_auth("<project_id>", "<api_token>")
request["Content-Type"] = 'application/json'
request.body = "{\n  \"whatsapp_business_id\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n  \"name\": \"order_update\",\n  \"language\": \"en_US\",\n  \"category\": \"utility\",\n  \"parameter_format\": \"positional\",\n  \"components\": [\n    {\n      \"type\": \"HEADER\",\n      \"example\": {\n        \"header_text\": [\n          \"Jane Smith\"\n        ]\n      },\n      \"format\": \"TEXT\",\n      \"text\": \"Order Update for {{1}}\"\n    },\n    {\n      \"type\": \"BODY\",\n      \"example\": {\n        \"body_text\": [\n          [\n            \"ORD-9821\",\n            \"out for delivery\"\n          ]\n        ]\n      },\n      \"text\": \"Your order {{1}} is currently {{2}}.\"\n    },\n    {\n      \"type\": \"FOOTER\",\n      \"text\": \"Thank you for shopping with us.\"\n    },\n    {\n      \"type\": \"BUTTONS\",\n      \"buttons\": [\n        {\n          \"text\": \"Track Order\",\n          \"type\": \"QUICK_REPLY\"\n        },\n        {\n          \"text\": \"Contact Support\",\n          \"type\": \"URL\",\n          \"url\": \"https://example.com/support\"\n        }\n      ]\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates")
  .basicAuth("<project_id>", "<api_token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"whatsapp_business_id\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n  \"name\": \"order_update\",\n  \"language\": \"en_US\",\n  \"category\": \"utility\",\n  \"parameter_format\": \"positional\",\n  \"components\": [\n    {\n      \"type\": \"HEADER\",\n      \"example\": {\n        \"header_text\": [\n          \"Jane Smith\"\n        ]\n      },\n      \"format\": \"TEXT\",\n      \"text\": \"Order Update for {{1}}\"\n    },\n    {\n      \"type\": \"BODY\",\n      \"example\": {\n        \"body_text\": [\n          [\n            \"ORD-9821\",\n            \"out for delivery\"\n          ]\n        ]\n      },\n      \"text\": \"Your order {{1}} is currently {{2}}.\"\n    },\n    {\n      \"type\": \"FOOTER\",\n      \"text\": \"Thank you for shopping with us.\"\n    },\n    {\n      \"type\": \"BUTTONS\",\n      \"buttons\": [\n        {\n          \"text\": \"Track Order\",\n          \"type\": \"QUICK_REPLY\"\n        },\n        {\n          \"text\": \"Contact Support\",\n          \"type\": \"URL\",\n          \"url\": \"https://example.com/support\"\n        }\n      ]\n    }\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates', [
  'body' => '{
  "whatsapp_business_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "name": "order_update",
  "language": "en_US",
  "category": "utility",
  "parameter_format": "positional",
  "components": [
    {
      "type": "HEADER",
      "example": {
        "header_text": [
          "Jane Smith"
        ]
      },
      "format": "TEXT",
      "text": "Order Update for {{1}}"
    },
    {
      "type": "BODY",
      "example": {
        "body_text": [
          [
            "ORD-9821",
            "out for delivery"
          ]
        ]
      },
      "text": "Your order {{1}} is currently {{2}}."
    },
    {
      "type": "FOOTER",
      "text": "Thank you for shopping with us."
    },
    {
      "type": "BUTTONS",
      "buttons": [
        {
          "text": "Track Order",
          "type": "QUICK_REPLY"
        },
        {
          "text": "Contact Support",
          "type": "URL",
          "url": "https://example.com/support"
        }
      ]
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<project_id>', '<api_token>'],
]);

echo $response->getBody();
```

```csharp
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates");
client.Authenticator = new HttpBasicAuthenticator("<project_id>", "<api_token>");
var request = new RestRequest(Method.POST);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"whatsapp_business_id\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n  \"name\": \"order_update\",\n  \"language\": \"en_US\",\n  \"category\": \"utility\",\n  \"parameter_format\": \"positional\",\n  \"components\": [\n    {\n      \"type\": \"HEADER\",\n      \"example\": {\n        \"header_text\": [\n          \"Jane Smith\"\n        ]\n      },\n      \"format\": \"TEXT\",\n      \"text\": \"Order Update for {{1}}\"\n    },\n    {\n      \"type\": \"BODY\",\n      \"example\": {\n        \"body_text\": [\n          [\n            \"ORD-9821\",\n            \"out for delivery\"\n          ]\n        ]\n      },\n      \"text\": \"Your order {{1}} is currently {{2}}.\"\n    },\n    {\n      \"type\": \"FOOTER\",\n      \"text\": \"Thank you for shopping with us.\"\n    },\n    {\n      \"type\": \"BUTTONS\",\n      \"buttons\": [\n        {\n          \"text\": \"Track Order\",\n          \"type\": \"QUICK_REPLY\"\n        },\n        {\n          \"text\": \"Contact Support\",\n          \"type\": \"URL\",\n          \"url\": \"https://example.com/support\"\n        }\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let credentials = Data("<project_id>:<api_token>".utf8).base64EncodedString()

let headers = [
  "Authorization": "Basic \(credentials)",
  "Content-Type": "application/json"
]
let parameters = [
  "whatsapp_business_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "name": "order_update",
  "language": "en_US",
  "category": "utility",
  "parameter_format": "positional",
  "components": [
    [
      "type": "HEADER",
      "example": ["header_text": ["Jane Smith"]],
      "format": "TEXT",
      "text": "Order Update for {{1}}"
    ],
    [
      "type": "BODY",
      "example": ["body_text": [["ORD-9821", "out for delivery"]]],
      "text": "Your order {{1}} is currently {{2}}."
    ],
    [
      "type": "FOOTER",
      "text": "Thank you for shopping with us."
    ],
    [
      "type": "BUTTONS",
      "buttons": [
        [
          "text": "Track Order",
          "type": "QUICK_REPLY"
        ],
        [
          "text": "Contact Support",
          "type": "URL",
          "url": "https://example.com/support"
        ]
      ]
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

## Approval and updates

Templates must be reviewed and approved by Meta before use. Approval typically takes a few minutes
to a few hours. A template's current state is reported in its `template_status` field. It must be
`approved` before it can be used to send messages.

A template can only be updated while it is **not yet approved**. Once approved, delete and recreate
it to make changes.

Anywhere a template ID is accepted, you can use either the SignalWire template ID (a UUID) or the
Meta template ID (a numeric string).