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

# Criar um template

POST https://dev.muchau.com.br/api/templates/
Content-Type: application/json

Cria e submete um novo template de mensagem para aprovação da Meta.

Reference: https://docs.muchau.com.br/api/reference/templates/criar-um-template

## Authentication

- `Authorization` header (bearer token, required) — API Key in the format `mk_live_<43-chars>`. Obtain from the Dashboard or `POST /auth/api-keys`.

## Request

### Body (application/json)

This endpoint expects an object.

- `wabaId` (string, required) — WhatsApp Business Account ID to create the template under
- `name` (string, required) — Template name using only lowercase letters, numbers, and underscores
- `language` (string, required) — Language code for the template (e.g., en_US, es_ES)
- `category` (enum, required) — Template category as required by Meta: MARKETING, UTILITY, or AUTHENTICATION
  - Allowed values: `MARKETING`, `UTILITY`, `AUTHENTICATION`
- `components` (list of map from string to any, required) — Array of template components (header, body, footer, buttons)

## Response

### 201

Default Response

- `id` (string, required) — Unique identifier of the template in the Muchaw platform
- `developerId` (string, required) — ID of the developer who owns this template
- `wabaId` (string, required) — WhatsApp Business Account ID this template belongs to
- `metaTemplateId` (string, required) — Template ID assigned by Meta
- `name` (string, required) — Template name
- `language` (string, required) — Language code of the template
- `category` (string, required) — Template category (MARKETING, UTILITY, or AUTHENTICATION)
- `status` (string, required) — Approval status of the template (e.g., APPROVED, PENDING, REJECTED)
- `components` (any, required) — Template components as returned by the WhatsApp Business API
- `createdAt` (string, required) — ISO 8601 datetime when the template was created
- `updatedAt` (string, required) — ISO 8601 datetime when the template was last updated

## Errors

### 400 Bad Request Error

Default Response

- `error` (ApiTemplatesPostResponsesContentApplicationJsonSchemaError, required)

### 401 Unauthorized Error

Default Response

- `error` (ApiTemplatesPostResponsesContentApplicationJsonSchemaError, required)

## Types

### ApiTemplatesPostResponsesContentApplicationJsonSchemaError

- `code` (string, required) — Machine-readable error code (e.g., UNAUTHORIZED, NOT_FOUND, VALIDATION_ERROR)
- `message` (string, required) — Human-readable error description
- `status` (integer, required) — HTTP status code
- `meta` (ApiTemplatesPostResponsesContentApplicationJsonSchemaErrorMeta, optional)
- `error_shield` (ApiTemplatesPostResponsesContentApplicationJsonSchemaErrorErrorShield, optional)

### ApiTemplatesPostResponsesContentApplicationJsonSchemaErrorMeta

- `meta_code` (integer, required)
- `meta_message` (string, required)
- `meta_subcode` (integer, required, nullable)
- `type` (string, required, nullable)
- `fbtrace_id` (string, required, nullable)
- `error_data` (any, optional)

### ApiTemplatesPostResponsesContentApplicationJsonSchemaErrorErrorShield

- ApiTemplatesPostResponsesContentApplicationJsonSchemaErrorErrorShield0
- ApiTemplatesPostResponsesContentApplicationJsonSchemaErrorErrorShield1

### ApiTemplatesPostResponsesContentApplicationJsonSchemaErrorErrorShield0

- `matched` (boolean, required)
- `entry_id` (string, required)
- `category` (enum, required)
  - Allowed values: `template`, `number`, `messaging`, `flow`, `permission`, `rate_limit`, `other`
- `severity` (enum, required)
  - Allowed values: `informational`, `recoverable`, `blocking`, `critical`
- `actor` (enum, required)
  - Allowed values: `developer`, `end_client`, `muchau`
- `human_message` (ApiTemplatesPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0HumanMessage, required)
- `action` (ApiTemplatesPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0Action, required)
- `action_url` (string, required, nullable)
- `docs_url` (string, required)
- `copy_text` (ApiTemplatesPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0CopyText, required)
- `version` (integer, required)
- `last_updated` (string, required)

### ApiTemplatesPostResponsesContentApplicationJsonSchemaErrorErrorShield1

- `matched` (boolean, required)
- `note` (ApiTemplatesPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf1Note, required)

### ApiTemplatesPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0HumanMessage

- `pt` (string, required)
- `en` (string, required)

### ApiTemplatesPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0Action

- `pt` (string, required)
- `en` (string, required)

### ApiTemplatesPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0CopyText

- `pt` (string, required, nullable)
- `en` (string, required, nullable)

### ApiTemplatesPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf1Note

- `pt` (string, required)
- `en` (string, required)

## Examples

**Request**

```json
{
  "wabaId": "123456789012345",
  "name": "promo_natal_2024",
  "language": "pt_BR",
  "category": "MARKETING",
  "components": [
    {}
  ]
}
```

**Response**

```json
{
  "id": "tpl_9876543210abcdef",
  "developerId": "dev_123abc456def789ghi",
  "wabaId": "123456789012345",
  "metaTemplateId": "meta_tpl_001122334455",
  "name": "promo_natal_2024",
  "language": "pt_BR",
  "category": "MARKETING",
  "status": "PENDING",
  "components": null,
  "createdAt": "2024-06-01T10:15:30Z",
  "updatedAt": "2024-06-01T10:15:30Z"
}
```

**SDK Code**

```python
import requests

url = "https://dev.muchau.com.br/api/templates/"

payload = {
    "wabaId": "123456789012345",
    "name": "promo_natal_2024",
    "language": "pt_BR",
    "category": "MARKETING",
    "components": [{}]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://dev.muchau.com.br/api/templates/';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"wabaId":"123456789012345","name":"promo_natal_2024","language":"pt_BR","category":"MARKETING","components":[{}]}'
};

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://dev.muchau.com.br/api/templates/"

	payload := strings.NewReader("{\n  \"wabaId\": \"123456789012345\",\n  \"name\": \"promo_natal_2024\",\n  \"language\": \"pt_BR\",\n  \"category\": \"MARKETING\",\n  \"components\": [\n    {}\n  ]\n}")

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

	req.Header.Add("Authorization", "Bearer <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://dev.muchau.com.br/api/templates/")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"wabaId\": \"123456789012345\",\n  \"name\": \"promo_natal_2024\",\n  \"language\": \"pt_BR\",\n  \"category\": \"MARKETING\",\n  \"components\": [\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://dev.muchau.com.br/api/templates/")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"wabaId\": \"123456789012345\",\n  \"name\": \"promo_natal_2024\",\n  \"language\": \"pt_BR\",\n  \"category\": \"MARKETING\",\n  \"components\": [\n    {}\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://dev.muchau.com.br/api/templates/', [
  'body' => '{
  "wabaId": "123456789012345",
  "name": "promo_natal_2024",
  "language": "pt_BR",
  "category": "MARKETING",
  "components": [
    {}
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://dev.muchau.com.br/api/templates/");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"wabaId\": \"123456789012345\",\n  \"name\": \"promo_natal_2024\",\n  \"language\": \"pt_BR\",\n  \"category\": \"MARKETING\",\n  \"components\": [\n    {}\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "wabaId": "123456789012345",
  "name": "promo_natal_2024",
  "language": "pt_BR",
  "category": "MARKETING",
  "components": [[]]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://dev.muchau.com.br/api/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()
```