# channel_connections.template_create

Criar um template de WhatsApp e enviar para análise. Cria o modelo na Meta (`POST /{waba}/message_templates`) e ele entra em análise. `name` com minúsculas, números e sublinhado; `category` `MARKETING` ou `UTILITY`; `language` (`pt_BR`, `pt_PT`, `en`, `es`...). `body` até 1024 caracteres, sem variável no começo nem no fim, e com `bodyExamples` (um exemplo por variável `{{1}}`, `{{2}}`...). Cabeçalho de texto (até 60, uma variável com `headerExample`), rodapé (até 60) e botões: até 3 de resposta ou 2 de link (variável só no fim da URL, com `example`). Cabeçalho de mídia, localização e autenticação ainda não.

- Endpoint: `POST https://app.atomiks.com.br/api/v1/channel_connections.template_create` (corpo JSON)
- Quem pode chamar: administrador da conta
- Escopo da chave: `channels:write`
- Grava dados: sim
- Pela chave de API: sim
- Ferramenta MCP: `channel_connections_template_create`
- Ficha em JSON: `https://app.atomiks.com.br/api/v1/openapi.json` (operationId `channel_connections.template_create`)

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `channelId` | string (uuid) | sim |  |
| `name` | string | sim |  |
| `category` | "MARKETING" \| "UTILITY" | sim |  |
| `language` | string | sim |  |
| `headerText` | string | não |  |
| `headerExample` | string | não |  |
| `body` | string | sim |  |
| `bodyExamples` | string[] | não | padrão [] |
| `footer` | string | não |  |
| `buttons` | object[] | não | padrão [] |

<details><summary>JSON Schema</summary>

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "channelId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "name": {
      "type": "string",
      "pattern": "^[a-z0-9_]{1,512}$"
    },
    "category": {
      "type": "string",
      "enum": [
        "MARKETING",
        "UTILITY"
      ]
    },
    "language": {
      "type": "string",
      "pattern": "^[a-z]{2}(_[A-Z]{2})?$"
    },
    "headerText": {
      "type": "string",
      "maxLength": 60
    },
    "headerExample": {
      "type": "string",
      "maxLength": 60
    },
    "body": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1024
    },
    "bodyExamples": {
      "default": [],
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 1024
      }
    },
    "footer": {
      "type": "string",
      "maxLength": 60
    },
    "buttons": {
      "default": [],
      "maxItems": 3,
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "QUICK_REPLY"
              },
              "text": {
                "type": "string",
                "minLength": 1,
                "maxLength": 25
              }
            },
            "required": [
              "type",
              "text"
            ]
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "URL"
              },
              "text": {
                "type": "string",
                "minLength": 1,
                "maxLength": 25
              },
              "url": {
                "type": "string",
                "maxLength": 2000
              },
              "example": {
                "type": "string",
                "maxLength": 2000
              }
            },
            "required": [
              "type",
              "text",
              "url"
            ]
          }
        ]
      }
    }
  },
  "required": [
    "channelId",
    "name",
    "category",
    "language",
    "body"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/channel_connections.template_create \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"channelId":"00000000-0000-0000-0000-000000000000","name":"boas_vindas","category":"UTILITY","language":"pt_BR","body":"Olá {{1}}, seu pedido foi recebido.","bodyExamples":["Ana"],"buttons":[]}'
```

CLI:

```bash
node cli/atomiks.mjs channel_connections.template_create --json '{"channelId":"00000000-0000-0000-0000-000000000000","name":"boas_vindas","category":"UTILITY","language":"pt_BR","body":"Olá {{1}}, seu pedido foi recebido.","bodyExamples":["Ana"],"buttons":[]}'
```

MCP: ferramenta `channel_connections_template_create` com a mesma entrada.

## Saída

Sucesso: `{"data": ...}` com o formato abaixo.

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "status": {
      "type": "string"
    },
    "category": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "status",
    "category"
  ],
  "additionalProperties": false
}
```

## Erros

`{"error": {"code", "message", "requestId"}}`. Códigos: `invalid_input` (400), `unauthorized` (401), `forbidden` / `account_pending` / `scope_missing` (403), `not_found` (404), `limit_reached` (409), `internal` (500).
