> ## Documentation Index
> Fetch the complete documentation index at: https://docs.grwthy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates

> Gerenciar templates de mensagem WhatsApp

# API de Templates

Gerencie templates de mensagem do WhatsApp Business. Templates devem ser aprovados pela Meta antes de serem usados para envio.

***

## Listar Templates

```bash theme={null}
GET https://grwthy.com/v1/templates
```

Retorna todos os templates do Business Account vinculado à API Key.

### Exemplo

```bash theme={null}
curl https://grwthy.com/v1/templates \
  -H "X-Api-Key: SUA_API_KEY"
```

### Resposta

```json theme={null}
{
  "data": [
    {
      "name": "hello_world",
      "status": "APPROVED",
      "category": "UTILITY",
      "language": "pt_BR",
      "components": [
        {
          "type": "BODY",
          "text": "Olá {{1}}! Bem-vindo ao nosso serviço."
        }
      ],
      "id": "123456789"
    }
  ]
}
```

### Status dos Templates

| Status     | Descrição            |
| ---------- | -------------------- |
| `APPROVED` | Pronto para uso      |
| `PENDING`  | Em análise pela Meta |
| `REJECTED` | Não aprovado         |

### Categorias

| Categoria        | Descrição                               |
| ---------------- | --------------------------------------- |
| `UTILITY`        | Atualizações de transação, notificações |
| `MARKETING`      | Mensagens promocionais, ofertas         |
| `AUTHENTICATION` | OTP e códigos de verificação            |

***

## Criar Template

```bash theme={null}
POST https://grwthy.com/v1/templates
```

<ParamField body="name" type="string" required>
  Nome do template (letras minúsculas e underscores).
</ParamField>

<ParamField body="category" type="string" required>
  Categoria: `UTILITY`, `MARKETING` ou `AUTHENTICATION`.
</ParamField>

<ParamField body="language" type="string" required>
  Código do idioma (ex: `pt_BR`, `en_US`).
</ParamField>

<ParamField body="components" type="array" required>
  Componentes do template (header, body, footer, buttons). Segue o formato da [API do WhatsApp](https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates).
</ParamField>

<ParamField body="allowCategoryChange" type="boolean">
  Permitir que a Meta reclassifique a categoria automaticamente.
</ParamField>

### Exemplo

```bash theme={null}
curl -X POST https://grwthy.com/v1/templates \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: SUA_API_KEY" \
  -d '{
    "name": "confirmacao_pedido",
    "category": "UTILITY",
    "language": "pt_BR",
    "components": [
      {
        "type": "BODY",
        "text": "Olá {{1}}, seu pedido {{2}} foi confirmado!"
      }
    ]
  }'
```

### Resposta

```json theme={null}
{
  "id": "987654321",
  "status": "PENDING",
  "category": "UTILITY"
}
```

***

## Editar Template

```bash theme={null}
PUT https://grwthy.com/v1/templates
```

<ParamField body="templateId" type="string" required>
  ID do template a ser editado.
</ParamField>

<ParamField body="components" type="array" required>
  Novos componentes do template.
</ParamField>

### Exemplo

```bash theme={null}
curl -X PUT https://grwthy.com/v1/templates \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: SUA_API_KEY" \
  -d '{
    "templateId": "987654321",
    "components": [
      {
        "type": "BODY",
        "text": "Olá {{1}}, seu pedido {{2}} foi confirmado e será entregue em {{3}}!"
      }
    ]
  }'
```

***

## Remover Template

```bash theme={null}
DELETE https://grwthy.com/v1/templates
```

<ParamField body="name" type="string" required>
  Nome do template a ser removido.
</ParamField>

<ParamField body="hsmId" type="string">
  HSM ID do template (opcional, para remoção específica).
</ParamField>

### Exemplo

```bash theme={null}
curl -X DELETE https://grwthy.com/v1/templates \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: SUA_API_KEY" \
  -d '{
    "name": "confirmacao_pedido"
  }'
```
