> ## 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.

# Instâncias

> Criar e gerenciar instâncias WhatsApp Business

# API de Instâncias

Gerencie instâncias WhatsApp Business. Cada instância representa uma linha WhatsApp conectada.

## Criar Instância

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

<ParamField body="instanceName" type="string" required>
  Nome único da instância. Usado como identificador nos endpoints de mensagem.
</ParamField>

<ParamField body="phoneNumberId" type="string" required>
  Phone Number ID do WhatsApp Business. Encontrado no painel Meta Business.
</ParamField>

<ParamField body="accessToken" type="string">
  Token de acesso permanente para a API do WhatsApp.
</ParamField>

<ParamField body="businessAccountId" type="string">
  ID da conta WhatsApp Business (WABA).
</ParamField>

<ParamField body="apiKey" type="string">
  Chave da API do WhatsApp Business.
</ParamField>

<ParamField body="webhook" type="object">
  Configuração de webhook para esta instância.

  <ParamField body="webhook.url" type="string" required>
    URL para receber eventos.
  </ParamField>

  <ParamField body="webhook.headers" type="object">
    Headers customizados enviados junto com cada evento.
  </ParamField>

  <ParamField body="webhook.enabled" type="boolean">
    Ativar ou desativar o webhook.
  </ParamField>

  <ParamField body="webhook.events" type="string[]">
    Lista de eventos para receber (ex: `["messages.upsert", "messages.update"]`).
  </ParamField>
</ParamField>

### Exemplo

```bash theme={null}
curl -X POST https://grwthy.com/v1/instances \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: SUA_API_KEY" \
  -d '{
    "instanceName": "minha-loja",
    "phoneNumberId": "123456789012345",
    "accessToken": "EAAx...",
    "webhook": {
      "url": "https://meusite.com/webhook",
      "enabled": true,
      "events": ["messages.upsert", "messages.update"]
    }
  }'
```

***

## Listar Instâncias

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

Retorna todas as instâncias do Business Account vinculado à API Key.

### Exemplo

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

***

## Buscar Instância

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

<ParamField path="id" type="string" required>
  ID da instância (retornado na criação).
</ParamField>

### Exemplo

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

***

## Remover Instância

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

<ParamField path="id" type="string" required>
  ID da instância.
</ParamField>

### Exemplo

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