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

# Mensagens

> Envie mensagens WhatsApp — texto, mídia, áudio, template, localização, contato, botões, lista e reação

# API de Mensagens

Envie mensagens WhatsApp via API. Todos os endpoints usam o ID da instância como parâmetro de rota.

```
POST https://grwthy.com/v1/messages/:type/:id
```

## Campos Comuns

Todos os tipos de mensagem (exceto reação) aceitam estes campos opcionais:

<ParamField body="quoted" type="object">
  Responder a uma mensagem específica.

  <ParamField body="quoted.id" type="string" required>
    ID da mensagem a ser respondida.
  </ParamField>
</ParamField>

<ParamField body="webhookUrl" type="string">
  URL customizada para receber o status desta mensagem.
</ParamField>

***

## Enviar Texto

```bash theme={null}
POST https://grwthy.com/v1/messages/text/:id
```

<ParamField body="number" type="string" required>
  Número do destinatário com código do país, sem `+`. Ex: `5511999999999`
</ParamField>

<ParamField body="text" type="string" required>
  Conteúdo da mensagem.
</ParamField>

<ParamField body="linkPreview" type="boolean">
  Habilitar pré-visualização de links. Padrão: `false`.
</ParamField>

### Exemplo

```bash theme={null}
curl -X POST https://grwthy.com/v1/messages/text/clux1a2b3c4d5e6f7g8h9i0j \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: SUA_API_KEY" \
  -d '{
    "number": "5511999999999",
    "text": "Olá do Grwthy!"
  }'
```

***

## Enviar Mídia

```bash theme={null}
POST https://grwthy.com/v1/messages/media/:id
```

<ParamField body="number" type="string" required>
  Número do destinatário.
</ParamField>

<ParamField body="mediatype" type="string" required>
  Tipo de mídia: `image`, `video` ou `document`.
</ParamField>

<ParamField body="media" type="string" required>
  URL pública da mídia ou conteúdo em base64.
</ParamField>

<ParamField body="mimetype" type="string">
  MIME type do arquivo (ex: `image/jpeg`, `application/pdf`).
</ParamField>

<ParamField body="caption" type="string">
  Legenda da mídia.
</ParamField>

<ParamField body="fileName" type="string">
  Nome do arquivo (usado para documentos).
</ParamField>

### Exemplo — Imagem

```bash theme={null}
curl -X POST https://grwthy.com/v1/messages/media/clux1a2b3c4d5e6f7g8h9i0j \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: SUA_API_KEY" \
  -d '{
    "number": "5511999999999",
    "mediatype": "image",
    "media": "https://exemplo.com/foto.jpg",
    "caption": "Confira nossa promoção!"
  }'
```

### Exemplo — Documento

```bash theme={null}
curl -X POST https://grwthy.com/v1/messages/media/clux1a2b3c4d5e6f7g8h9i0j \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: SUA_API_KEY" \
  -d '{
    "number": "5511999999999",
    "mediatype": "document",
    "media": "https://exemplo.com/relatorio.pdf",
    "fileName": "relatorio-mensal.pdf"
  }'
```

***

## Enviar Áudio

```bash theme={null}
POST https://grwthy.com/v1/messages/audio/:id
```

<ParamField body="number" type="string" required>
  Número do destinatário.
</ParamField>

<ParamField body="audio" type="string" required>
  URL pública do áudio ou conteúdo em base64.
</ParamField>

<ParamField body="mimetype" type="string">
  MIME type do áudio. Formatos aceitos pela Meta: `audio/aac`, `audio/mp4`, `audio/mpeg`, `audio/amr`, `audio/ogg`, `audio/opus`.
</ParamField>

### Exemplo

```bash theme={null}
curl -X POST https://grwthy.com/v1/messages/audio/clux1a2b3c4d5e6f7g8h9i0j \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: SUA_API_KEY" \
  -d '{
    "number": "5511999999999",
    "audio": "https://exemplo.com/audio.ogg",
    "mimetype": "audio/ogg"
  }'
```

***

## Enviar Template

```bash theme={null}
POST https://grwthy.com/v1/messages/template/:id
```

Templates devem ser pré-aprovados no seu WhatsApp Business Account.

<ParamField body="number" type="string" required>
  Número do destinatário.
</ParamField>

<ParamField body="name" type="string" required>
  Nome do template aprovado.
</ParamField>

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

<ParamField body="components" type="array">
  Componentes com parâmetros dinâmicos. Segue o formato da [API do WhatsApp](https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#template-object).
</ParamField>

### Exemplo

```bash theme={null}
curl -X POST https://grwthy.com/v1/messages/template/clux1a2b3c4d5e6f7g8h9i0j \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: SUA_API_KEY" \
  -d '{
    "number": "5511999999999",
    "name": "confirmacao_pedido",
    "language": "pt_BR",
    "components": [
      {
        "type": "body",
        "parameters": [
          { "type": "text", "text": "João" },
          { "type": "text", "text": "#12345" }
        ]
      }
    ]
  }'
```

***

## Enviar Localização

```bash theme={null}
POST https://grwthy.com/v1/messages/location/:id
```

<ParamField body="number" type="string" required>
  Número do destinatário.
</ParamField>

<ParamField body="latitude" type="number" required>
  Latitude.
</ParamField>

<ParamField body="longitude" type="number" required>
  Longitude.
</ParamField>

<ParamField body="name" type="string">
  Nome do local.
</ParamField>

<ParamField body="address" type="string">
  Endereço do local.
</ParamField>

### Exemplo

```bash theme={null}
curl -X POST https://grwthy.com/v1/messages/location/clux1a2b3c4d5e6f7g8h9i0j \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: SUA_API_KEY" \
  -d '{
    "number": "5511999999999",
    "latitude": -23.5505,
    "longitude": -46.6333,
    "name": "São Paulo",
    "address": "Av. Paulista, 1000"
  }'
```

***

## Enviar Contato

```bash theme={null}
POST https://grwthy.com/v1/messages/contact/:id
```

<ParamField body="number" type="string" required>
  Número do destinatário.
</ParamField>

<ParamField body="contact" type="array" required>
  Lista de contatos a enviar.

  <ParamField body="contact[].fullName" type="string" required>
    Nome completo do contato.
  </ParamField>

  <ParamField body="contact[].phoneNumber" type="string" required>
    Telefone do contato.
  </ParamField>

  <ParamField body="contact[].organization" type="string">
    Empresa.
  </ParamField>

  <ParamField body="contact[].email" type="string">
    E-mail.
  </ParamField>

  <ParamField body="contact[].url" type="string">
    Website.
  </ParamField>
</ParamField>

### Exemplo

```bash theme={null}
curl -X POST https://grwthy.com/v1/messages/contact/clux1a2b3c4d5e6f7g8h9i0j \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: SUA_API_KEY" \
  -d '{
    "number": "5511999999999",
    "contact": [
      {
        "fullName": "João Silva",
        "phoneNumber": "5511888888888",
        "organization": "Grwthy"
      }
    ]
  }'
```

***

## Enviar Botões

```bash theme={null}
POST https://grwthy.com/v1/messages/buttons/:id
```

<ParamField body="number" type="string" required>
  Número do destinatário.
</ParamField>

<ParamField body="title" type="string" required>
  Título da mensagem.
</ParamField>

<ParamField body="buttons" type="array" required>
  Lista de botões (máximo 3).

  <ParamField body="buttons[].reply.id" type="string" required>
    ID do botão (retornado quando o usuário clica).
  </ParamField>

  <ParamField body="buttons[].reply.title" type="string" required>
    Texto exibido no botão.
  </ParamField>
</ParamField>

### Exemplo

```bash theme={null}
curl -X POST https://grwthy.com/v1/messages/buttons/clux1a2b3c4d5e6f7g8h9i0j \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: SUA_API_KEY" \
  -d '{
    "number": "5511999999999",
    "title": "Como podemos ajudar?",
    "buttons": [
      { "reply": { "id": "btn_vendas", "title": "Vendas" } },
      { "reply": { "id": "btn_suporte", "title": "Suporte" } },
      { "reply": { "id": "btn_horario", "title": "Horários" } }
    ]
  }'
```

***

## Enviar Lista

```bash theme={null}
POST https://grwthy.com/v1/messages/list/:id
```

<ParamField body="number" type="string" required>
  Número do destinatário.
</ParamField>

<ParamField body="title" type="string" required>
  Título da mensagem.
</ParamField>

<ParamField body="buttonText" type="string" required>
  Texto do botão que abre a lista.
</ParamField>

<ParamField body="description" type="string">
  Descrição da mensagem.
</ParamField>

<ParamField body="footerText" type="string">
  Texto do rodapé.
</ParamField>

<ParamField body="sections" type="array" required>
  Seções da lista.

  <ParamField body="sections[].title" type="string" required>
    Título da seção.
  </ParamField>

  <ParamField body="sections[].rows" type="array" required>
    Itens da seção.

    <ParamField body="sections[].rows[].id" type="string" required>
      ID do item.
    </ParamField>

    <ParamField body="sections[].rows[].title" type="string" required>
      Título do item.
    </ParamField>

    <ParamField body="sections[].rows[].description" type="string">
      Descrição do item.
    </ParamField>
  </ParamField>
</ParamField>

### Exemplo

```bash theme={null}
curl -X POST https://grwthy.com/v1/messages/list/clux1a2b3c4d5e6f7g8h9i0j \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: SUA_API_KEY" \
  -d '{
    "number": "5511999999999",
    "title": "Nossos serviços",
    "buttonText": "Ver opções",
    "sections": [
      {
        "title": "Planos",
        "rows": [
          { "id": "starter", "title": "Starter", "description": "Para pequenos negócios" },
          { "id": "pro", "title": "Pro", "description": "Para empresas em crescimento" }
        ]
      }
    ]
  }'
```

***

## Enviar Reação

```bash theme={null}
POST https://grwthy.com/v1/messages/reaction/:id
```

<ParamField body="number" type="string" required>
  Número do destinatário.
</ParamField>

<ParamField body="messageId" type="string" required>
  ID da mensagem (wamid) para reagir.
</ParamField>

<ParamField body="reaction" type="string" required>
  Emoji da reação. Envie string vazia `""` para remover a reação.
</ParamField>

### Exemplo

```bash theme={null}
curl -X POST https://grwthy.com/v1/messages/reaction/clux1a2b3c4d5e6f7g8h9i0j \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: SUA_API_KEY" \
  -d '{
    "number": "5511999999999",
    "messageId": "wamid.HBgNNTUxMTk5OTk5OTk5FQIAEhgUM0EB",
    "reaction": "👍"
  }'
```
