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

# Enviar Mensagem

> Envia uma mensagem de texto ou mídia

## Request Body

<ParamField body="channel_id" type="string" required>
  UUID do canal
</ParamField>

<ParamField body="remote_jid" type="string" required>
  JID do WhatsApp (ex: `5511999999999@s.whatsapp.net`)
</ParamField>

<ParamField body="content" type="string" required>
  Conteúdo da mensagem (texto ou legenda para mídia)
</ParamField>

<ParamField body="message_type" type="string" default="text">
  Tipo: `text`, `image`, `video`, `audio`, `document`
</ParamField>

<ParamField body="url" type="string">
  URL da mídia (obrigatório para tipos diferentes de `text`)
</ParamField>

## Enviar Mensagem de Texto

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.leavo.ai/backend/messages/send" \
    -H "Authorization: Bearer sua_chave_aqui" \
    -H "Content-Type: application/json" \
    -d '{
      "channel_id": "uuid-do-canal",
      "remote_jid": "5511999999999@s.whatsapp.net",
      "content": "Olá! Como posso ajudar?",
      "message_type": "text"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.leavo.ai/backend/messages/send', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer sua_chave_aqui',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      channel_id: 'uuid-do-canal',
      remote_jid: '5511999999999@s.whatsapp.net',
      content: 'Olá! Como posso ajudar?',
      message_type: 'text'
    })
  });

  const result = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.leavo.ai/backend/messages/send',
      headers={
          'Authorization': 'Bearer sua_chave_aqui',
          'Content-Type': 'application/json'
      },
      json={
          'channel_id': 'uuid-do-canal',
          'remote_jid': '5511999999999@s.whatsapp.net',
          'content': 'Olá! Como posso ajudar?',
          'message_type': 'text'
      }
  )
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "success": true,
    "message_id": "msg-uuid",
    "timestamp": "2024-01-15T10:30:00Z"
  }
  ```
</ResponseExample>

## Enviar Mensagem com Mídia

<RequestExample>
  ```bash cURL - Imagem theme={null}
  curl -X POST "https://api.leavo.ai/backend/messages/send" \
    -H "Authorization: Bearer sua_chave_aqui" \
    -H "Content-Type: application/json" \
    -d '{
      "channel_id": "uuid-do-canal",
      "remote_jid": "5511999999999@s.whatsapp.net",
      "content": "Veja nossa proposta!",
      "message_type": "image",
      "url": "https://exemplo.com/proposta.jpg"
    }'
  ```

  ```bash cURL - Documento theme={null}
  curl -X POST "https://api.leavo.ai/backend/messages/send" \
    -H "Authorization: Bearer sua_chave_aqui" \
    -H "Content-Type: application/json" \
    -d '{
      "channel_id": "uuid-do-canal",
      "remote_jid": "5511999999999@s.whatsapp.net",
      "content": "Segue o contrato em anexo",
      "message_type": "document",
      "url": "https://exemplo.com/contrato.pdf"
    }'
  ```
</RequestExample>

## Tipos de Mídia Suportados

| Tipo       | Formatos           | Tamanho Máximo |
| ---------- | ------------------ | -------------- |
| `image`    | JPG, PNG, GIF      | 16 MB          |
| `video`    | MP4, 3GP           | 64 MB          |
| `audio`    | MP3, OGG, M4A      | 16 MB          |
| `document` | PDF, DOC, XLS, etc | 100 MB         |

<Warning>
  A URL da mídia deve ser acessível publicamente. O servidor faz download da mídia antes de enviar.
</Warning>
