> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.chatbridge.mx/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.chatbridge.mx/_mcp/server.

# Create template

POST https://connect.chatbridge.mx/v1/whatsapp/templates
Content-Type: application/json

Creates a new template and submits it to Meta for approval. The template is created in `PENDING` status; Meta reviews it within approximately 1 to 24 hours. The `BODY` component is required except for carousel-type templates.

Reference: https://docs.chatbridge.mx/whats-app/templates/create-template

## Authentication

- `x-api-key` header (required) — Account authentication key.
- `Authorization` header (bearer token, required) — OAuth 2.0 access token issued by `POST /api/oauth/token` (client-credentials). Takes precedence over `x-api-key` when both are sent. See the Authentication section.

## Request

### Body (application/json)

This endpoint expects a TemplateCreateRequest.

- `name` (string, required) — Unique template name (snake_case, lowercase only).
- `category` (enum, required)
  - Allowed values: `MARKETING`, `UTILITY`, `AUTHENTICATION`
- `parameter_format` (enum, required) — Variable format. POSITIONAL uses \{\{1}}, \{\{2}}; NAMED uses \{\{name}}. The two formats cannot be mixed in a single template.
  - Allowed values: `POSITIONAL`, `NAMED`
- `language` (string, required)
- `components` (list of TemplateComponent, required) — Template components. Must include at least one BODY.
- `message_send_ttl_seconds` (integer, optional) — Message time-to-live, in seconds. Optional.

## Response

### 200

Template created in PENDING status.

- `_id` (string, optional)
- `whatsapp_account` (string, optional)
- `name` (string, optional)
- `category` (enum, optional)
  - Allowed values: `MARKETING`, `UTILITY`, `AUTHENTICATION`
- `language` (string, optional)
- `status` (enum, optional)
  - Allowed values: `APPROVED`, `PENDING`, `REJECTED`
- `parameter_format` (enum, optional) — Variable format. POSITIONAL uses \{\{1}}, \{\{2}}; NAMED uses \{\{name}}. The two formats cannot be mixed in a single template.
  - Allowed values: `POSITIONAL`, `NAMED`
- `components` (list of TemplateComponent, optional)

## Errors

### 400 Bad Request Error

The request contains invalid data.

- `message` (string, optional)
- `error` (string, optional)
- `statusCode` (integer, optional)
- `errorCode` (integer, optional)
- `metadata` (map from string to any, optional)

### 409 Conflict Error

A template with the same name already exists in the account.

- `message` (string, optional)
- `error` (string, optional)
- `statusCode` (integer, optional)
- `errorCode` (integer, optional)
- `metadata` (map from string to any, optional)

## Types

### TemplateComponent

Template component. Depending on the value of `type`, different fields apply (HEADER, BODY, FOOTER, BUTTONS, or CAROUSEL).

- `type` (enum, required)
  - Allowed values: `HEADER`, `BODY`, `FOOTER`, `BUTTONS`, `CAROUSEL`
- `format` (enum, optional) — Applies to HEADER.
  - Allowed values: `TEXT`, `IMAGE`, `VIDEO`, `DOCUMENT`, `LOCATION`
- `text` (string, optional) — Component text (HEADER TEXT, BODY, FOOTER).
- `url` (string, optional) — Resource URL for a HEADER of type IMAGE, VIDEO, or DOCUMENT.
- `location` (Location, optional)
- `add_security_recommendation` (boolean, optional) — Applies to the BODY of AUTHENTICATION templates.
- `code_expiration_minutes` (integer, optional) — Applies to the FOOTER of AUTHENTICATION templates.
- `example` (map from string to any, optional) — Example values required when the component has variables.
- `buttons` (list of TemplateButton, optional)
- `cards` (list of TemplateComponentCardsItems, optional) — Carousel cards (minimum 2, maximum 10).

### Location

- `latitude` (double, optional)
- `longitude` (double, optional)
- `name` (string, optional)
- `address` (string, optional)

### TemplateButton

- `type` (enum, optional)
  - Allowed values: `QUICK_REPLY`, `URL`, `PHONE_NUMBER`, `COPY_CODE`, `OTP`
- `text` (string, optional)
- `url` (string, optional) — Applies to URL buttons. Supports one \{\{1}} variable.
- `phone_number` (string, optional) — Applies to PHONE_NUMBER buttons. E.164 format.
- `otp_type` (enum, optional) — Applies to OTP buttons.
  - Allowed values: `COPY_CODE`
- `example` (list of string, optional)

### TemplateComponentCardsItems

- `components` (list of TemplateComponent, optional)

## Examples

### Registration confirmation (BODY only)

**Request**

```json
{
  "name": "confirmacion_registro",
  "category": "UTILITY",
  "parameter_format": "POSITIONAL",
  "language": "es_MX",
  "components": [
    {
      "type": "BODY",
      "text": "¡Hola {{1}}! Tu registro ha sido exitoso. Usuario: {{2}}",
      "example": {
        "body_text": [
          [
            "María",
            "maria@email.com"
          ]
        ]
      }
    }
  ]
}
```

**Response**

```json
{
  "_id": "string",
  "whatsapp_account": "string",
  "name": "string",
  "category": "MARKETING",
  "language": "es_MX",
  "status": "APPROVED",
  "parameter_format": "POSITIONAL",
  "components": [
    {
      "type": "HEADER",
      "format": "TEXT",
      "text": "string",
      "url": "string",
      "location": {
        "latitude": 1.1,
        "longitude": 1.1,
        "name": "string",
        "address": "string"
      },
      "add_security_recommendation": true,
      "code_expiration_minutes": 1,
      "example": {},
      "buttons": [
        {
          "type": "QUICK_REPLY",
          "text": "string",
          "url": "string",
          "phone_number": "string",
          "otp_type": "COPY_CODE",
          "example": [
            "string"
          ]
        }
      ],
      "cards": [
        {
          "components": [
            null
          ]
        }
      ]
    }
  ]
}
```

**SDK Code**

```python Registration confirmation (BODY only)
import requests

url = "https://connect.chatbridge.mx/v1/whatsapp/templates"

payload = {
    "name": "confirmacion_registro",
    "category": "UTILITY",
    "parameter_format": "POSITIONAL",
    "language": "es_MX",
    "components": [
        {
            "type": "BODY",
            "text": "¡Hola {{1}}! Tu registro ha sido exitoso. Usuario: {{2}}",
            "example": { "body_text": [["María", "maria@email.com"]] }
        }
    ]
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Registration confirmation (BODY only)
const url = 'https://connect.chatbridge.mx/v1/whatsapp/templates';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"name":"confirmacion_registro","category":"UTILITY","parameter_format":"POSITIONAL","language":"es_MX","components":[{"type":"BODY","text":"¡Hola {{1}}! Tu registro ha sido exitoso. Usuario: {{2}}","example":{"body_text":[["María","maria@email.com"]]}}]}'
};

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

```go Registration confirmation (BODY only)
package main

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

func main() {

	url := "https://connect.chatbridge.mx/v1/whatsapp/templates"

	payload := strings.NewReader("{\n  \"name\": \"confirmacion_registro\",\n  \"category\": \"UTILITY\",\n  \"parameter_format\": \"POSITIONAL\",\n  \"language\": \"es_MX\",\n  \"components\": [\n    {\n      \"type\": \"BODY\",\n      \"text\": \"¡Hola {{1}}! Tu registro ha sido exitoso. Usuario: {{2}}\",\n      \"example\": {\n        \"body_text\": [\n          [\n            \"María\",\n            \"maria@email.com\"\n          ]\n        ]\n      }\n    }\n  ]\n}")

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

	req.Header.Add("x-api-key", "<apiKey>")
	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 Registration confirmation (BODY only)
require 'uri'
require 'net/http'

url = URI("https://connect.chatbridge.mx/v1/whatsapp/templates")

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

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"confirmacion_registro\",\n  \"category\": \"UTILITY\",\n  \"parameter_format\": \"POSITIONAL\",\n  \"language\": \"es_MX\",\n  \"components\": [\n    {\n      \"type\": \"BODY\",\n      \"text\": \"¡Hola {{1}}! Tu registro ha sido exitoso. Usuario: {{2}}\",\n      \"example\": {\n        \"body_text\": [\n          [\n            \"María\",\n            \"maria@email.com\"\n          ]\n        ]\n      }\n    }\n  ]\n}"

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

```java Registration confirmation (BODY only)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://connect.chatbridge.mx/v1/whatsapp/templates")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"confirmacion_registro\",\n  \"category\": \"UTILITY\",\n  \"parameter_format\": \"POSITIONAL\",\n  \"language\": \"es_MX\",\n  \"components\": [\n    {\n      \"type\": \"BODY\",\n      \"text\": \"¡Hola {{1}}! Tu registro ha sido exitoso. Usuario: {{2}}\",\n      \"example\": {\n        \"body_text\": [\n          [\n            \"María\",\n            \"maria@email.com\"\n          ]\n        ]\n      }\n    }\n  ]\n}")
  .asString();
```

```php Registration confirmation (BODY only)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://connect.chatbridge.mx/v1/whatsapp/templates', [
  'body' => '{
  "name": "confirmacion_registro",
  "category": "UTILITY",
  "parameter_format": "POSITIONAL",
  "language": "es_MX",
  "components": [
    {
      "type": "BODY",
      "text": "¡Hola {{1}}! Tu registro ha sido exitoso. Usuario: {{2}}",
      "example": {
        "body_text": [
          [
            "María",
            "maria@email.com"
          ]
        ]
      }
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Registration confirmation (BODY only)
using RestSharp;

var client = new RestClient("https://connect.chatbridge.mx/v1/whatsapp/templates");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"confirmacion_registro\",\n  \"category\": \"UTILITY\",\n  \"parameter_format\": \"POSITIONAL\",\n  \"language\": \"es_MX\",\n  \"components\": [\n    {\n      \"type\": \"BODY\",\n      \"text\": \"¡Hola {{1}}! Tu registro ha sido exitoso. Usuario: {{2}}\",\n      \"example\": {\n        \"body_text\": [\n          [\n            \"María\",\n            \"maria@email.com\"\n          ]\n        ]\n      }\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Registration confirmation (BODY only)
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "confirmacion_registro",
  "category": "UTILITY",
  "parameter_format": "POSITIONAL",
  "language": "es_MX",
  "components": [
    [
      "type": "BODY",
      "text": "¡Hola {{1}}! Tu registro ha sido exitoso. Usuario: {{2}}",
      "example": ["body_text": [["María", "maria@email.com"]]]
    ]
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://connect.chatbridge.mx/v1/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()
```

### Authentication code (OTP)

**Request**

```json
{
  "name": "verificacion_acceso",
  "category": "AUTHENTICATION",
  "parameter_format": "POSITIONAL",
  "language": "es_MX",
  "components": [
    {
      "type": "BODY",
      "add_security_recommendation": true
    },
    {
      "type": "FOOTER",
      "code_expiration_minutes": 10
    },
    {
      "type": "BUTTONS",
      "buttons": [
        {
          "type": "OTP",
          "text": "Copy code",
          "otp_type": "COPY_CODE"
        }
      ]
    }
  ],
  "message_send_ttl_seconds": 300
}
```

**Response**

```json
{
  "_id": "string",
  "whatsapp_account": "string",
  "name": "string",
  "category": "MARKETING",
  "language": "es_MX",
  "status": "APPROVED",
  "parameter_format": "POSITIONAL",
  "components": [
    {
      "type": "HEADER",
      "format": "TEXT",
      "text": "string",
      "url": "string",
      "location": {
        "latitude": 1.1,
        "longitude": 1.1,
        "name": "string",
        "address": "string"
      },
      "add_security_recommendation": true,
      "code_expiration_minutes": 1,
      "example": {},
      "buttons": [
        {
          "type": "QUICK_REPLY",
          "text": "string",
          "url": "string",
          "phone_number": "string",
          "otp_type": "COPY_CODE",
          "example": [
            "string"
          ]
        }
      ],
      "cards": [
        {
          "components": [
            null
          ]
        }
      ]
    }
  ]
}
```

**SDK Code**

```python Authentication code (OTP)
import requests

url = "https://connect.chatbridge.mx/v1/whatsapp/templates"

payload = {
    "name": "verificacion_acceso",
    "category": "AUTHENTICATION",
    "parameter_format": "POSITIONAL",
    "language": "es_MX",
    "components": [
        {
            "type": "BODY",
            "add_security_recommendation": True
        },
        {
            "type": "FOOTER",
            "code_expiration_minutes": 10
        },
        {
            "type": "BUTTONS",
            "buttons": [
                {
                    "type": "OTP",
                    "text": "Copy code",
                    "otp_type": "COPY_CODE"
                }
            ]
        }
    ],
    "message_send_ttl_seconds": 300
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Authentication code (OTP)
const url = 'https://connect.chatbridge.mx/v1/whatsapp/templates';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"name":"verificacion_acceso","category":"AUTHENTICATION","parameter_format":"POSITIONAL","language":"es_MX","components":[{"type":"BODY","add_security_recommendation":true},{"type":"FOOTER","code_expiration_minutes":10},{"type":"BUTTONS","buttons":[{"type":"OTP","text":"Copy code","otp_type":"COPY_CODE"}]}],"message_send_ttl_seconds":300}'
};

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

```go Authentication code (OTP)
package main

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

func main() {

	url := "https://connect.chatbridge.mx/v1/whatsapp/templates"

	payload := strings.NewReader("{\n  \"name\": \"verificacion_acceso\",\n  \"category\": \"AUTHENTICATION\",\n  \"parameter_format\": \"POSITIONAL\",\n  \"language\": \"es_MX\",\n  \"components\": [\n    {\n      \"type\": \"BODY\",\n      \"add_security_recommendation\": true\n    },\n    {\n      \"type\": \"FOOTER\",\n      \"code_expiration_minutes\": 10\n    },\n    {\n      \"type\": \"BUTTONS\",\n      \"buttons\": [\n        {\n          \"type\": \"OTP\",\n          \"text\": \"Copy code\",\n          \"otp_type\": \"COPY_CODE\"\n        }\n      ]\n    }\n  ],\n  \"message_send_ttl_seconds\": 300\n}")

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

	req.Header.Add("x-api-key", "<apiKey>")
	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 Authentication code (OTP)
require 'uri'
require 'net/http'

url = URI("https://connect.chatbridge.mx/v1/whatsapp/templates")

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

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"verificacion_acceso\",\n  \"category\": \"AUTHENTICATION\",\n  \"parameter_format\": \"POSITIONAL\",\n  \"language\": \"es_MX\",\n  \"components\": [\n    {\n      \"type\": \"BODY\",\n      \"add_security_recommendation\": true\n    },\n    {\n      \"type\": \"FOOTER\",\n      \"code_expiration_minutes\": 10\n    },\n    {\n      \"type\": \"BUTTONS\",\n      \"buttons\": [\n        {\n          \"type\": \"OTP\",\n          \"text\": \"Copy code\",\n          \"otp_type\": \"COPY_CODE\"\n        }\n      ]\n    }\n  ],\n  \"message_send_ttl_seconds\": 300\n}"

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

```java Authentication code (OTP)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://connect.chatbridge.mx/v1/whatsapp/templates")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"verificacion_acceso\",\n  \"category\": \"AUTHENTICATION\",\n  \"parameter_format\": \"POSITIONAL\",\n  \"language\": \"es_MX\",\n  \"components\": [\n    {\n      \"type\": \"BODY\",\n      \"add_security_recommendation\": true\n    },\n    {\n      \"type\": \"FOOTER\",\n      \"code_expiration_minutes\": 10\n    },\n    {\n      \"type\": \"BUTTONS\",\n      \"buttons\": [\n        {\n          \"type\": \"OTP\",\n          \"text\": \"Copy code\",\n          \"otp_type\": \"COPY_CODE\"\n        }\n      ]\n    }\n  ],\n  \"message_send_ttl_seconds\": 300\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://connect.chatbridge.mx/v1/whatsapp/templates', [
  'body' => '{
  "name": "verificacion_acceso",
  "category": "AUTHENTICATION",
  "parameter_format": "POSITIONAL",
  "language": "es_MX",
  "components": [
    {
      "type": "BODY",
      "add_security_recommendation": true
    },
    {
      "type": "FOOTER",
      "code_expiration_minutes": 10
    },
    {
      "type": "BUTTONS",
      "buttons": [
        {
          "type": "OTP",
          "text": "Copy code",
          "otp_type": "COPY_CODE"
        }
      ]
    }
  ],
  "message_send_ttl_seconds": 300
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Authentication code (OTP)
using RestSharp;

var client = new RestClient("https://connect.chatbridge.mx/v1/whatsapp/templates");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"verificacion_acceso\",\n  \"category\": \"AUTHENTICATION\",\n  \"parameter_format\": \"POSITIONAL\",\n  \"language\": \"es_MX\",\n  \"components\": [\n    {\n      \"type\": \"BODY\",\n      \"add_security_recommendation\": true\n    },\n    {\n      \"type\": \"FOOTER\",\n      \"code_expiration_minutes\": 10\n    },\n    {\n      \"type\": \"BUTTONS\",\n      \"buttons\": [\n        {\n          \"type\": \"OTP\",\n          \"text\": \"Copy code\",\n          \"otp_type\": \"COPY_CODE\"\n        }\n      ]\n    }\n  ],\n  \"message_send_ttl_seconds\": 300\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Authentication code (OTP)
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "verificacion_acceso",
  "category": "AUTHENTICATION",
  "parameter_format": "POSITIONAL",
  "language": "es_MX",
  "components": [
    [
      "type": "BODY",
      "add_security_recommendation": true
    ],
    [
      "type": "FOOTER",
      "code_expiration_minutes": 10
    ],
    [
      "type": "BUTTONS",
      "buttons": [
        [
          "type": "OTP",
          "text": "Copy code",
          "otp_type": "COPY_CODE"
        ]
      ]
    ]
  ],
  "message_send_ttl_seconds": 300
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://connect.chatbridge.mx/v1/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()
```