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

# Enviar Mensagem de Texto

> Enviar mensagem de texto para um contato ou grupo

## Descrição

Este endpoint permite enviar mensagens de texto simples para contatos individuais ou grupos no WhatsApp. Também é possível responder a mensagens específicas usando o parâmetro `replyTo`.

## Body

```json theme={null}
{
  "sessionId": "my-session",
  "jid": "5511999999999@s.whatsapp.net",
  "text": "Olá, como vai?",
  "replyTo": "valor"
}
```

### Parâmetros do Body

| Propriedade | Tipo     | Obrigatório | Descrição                                                                                                                                |
| ----------- | -------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `sessionId` | `string` | ✅ Sim       | ID da sessão autenticada que enviará a mensagem                                                                                          |
| `jid`       | `string` | ✅ Sim       | Identificador do destinatário (JID do WhatsApp). Formato: `5511999999999@s.whatsapp.net` para contatos ou `120363XXXXX@g.us` para grupos |
| `text`      | `string` | ✅ Sim       | Conteúdo da mensagem de texto a ser enviada                                                                                              |
| `replyTo`   | `string` | ❌ Não       | ID da mensagem à qual você deseja responder (para criar uma thread de conversa)                                                          |

<ResponseExample>
  ```json Resposta de Sucesso theme={null}
  {
    "success": true,
    "messageId": "3EB0XXXXXX"
  }
  ```
</ResponseExample>

## Códigos de Status

* `200` - Mensagem enviada com sucesso
* `400` - Parâmetros inválidos
* `401` - Sessão não autorizada
* `404` - Sessão não encontrada

## Exemplo de Uso

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.com.br/api/sendText \
    -H "Content-Type: application/json" \
    -d '{
      "sessionId": "my-session",
      "jid": "5511999999999@s.whatsapp.net",
      "text": "Olá, como vai?"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.wappfy.com.br/api/sendText', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      sessionId: 'my-session',
      jid: '5511999999999@s.whatsapp.net',
      text: 'Olá, como vai?',
      replyTo: '3EB0XXXXXX' // opcional
    })
  });
  const data = await response.json();
  console.log(data);
  ```

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

  response = requests.post(
      'https://api.wappfy.com.br/api/sendText',
      json={
          'sessionId': 'my-session',
          'jid': '5511999999999@s.whatsapp.net',
          'text': 'Olá, como vai?',
          'replyTo': '3EB0XXXXXX'  # opcional
      }
  )
  data = response.json()
  print(data)
  ```
</CodeGroup>


## OpenAPI

````yaml viewer.json post /api/sendText
openapi: 3.1.0
info:
  title: Wappfy - WhatsApp HTTP API
  version: '2.0'
  contact: {}
servers:
  - url: https://{host}
    description: Servidor Customizável
    variables:
      host:
        default: api.wappfy.com.br
        description: 'URL do servidor (ex: api.wappfy.com.br ou seu-servidor.com)'
security:
  - api_key: []
tags:
  - name: 🖥️ Sessions
    description: >-
      Controlar sessões do WhatsApp (contas) (Control WhatsApp sessions
      (accounts))
  - name: 🔑 Auth
    description: Autenticação
  - name: 🆔 Profile
    description: Informações do seu perfil
  - name: 🖼️ Screenshot
    description: Obter captura de tela do WhatsApp e mostrar código QR
  - name: 📤 Chatting
    description: Métodos de conversação
  - name: 📢 Channels
    description: Métodos de canais (newsletters) (Channels (newsletters) methods)
  - name: 🟢 Status
    description: Métodos de status (aka stories) (Status (aka stories) methods)
  - name: 💬 Chats
    description: Métodos de conversas
  - name: 👤 Contacts
    description: >-
      Métodos de contatos. Use número de telefone (sem +) ou número de telefone
      e `@c.us` no final como `contactId`. Ex: `12312312310` OU
      `12312312310@c.us` (Contacts methods.<br>
                      Use phone number (without +) or phone number and `@c.us` at the end as `contactId`.<br>
                      'E.g: `12312312310` OR `12312312310@c.us`<br>)
  - name: 👥 Groups
    description: Métodos de grupos (Groups methods).<br>
  - name: ✅ Presence
    description: Informações de presença
  - name: 📅 Events
    description: Mensagem de Evento
  - name: 🏷️ Labels
    description: Etiquetas - disponível apenas para contas WhatsApp Business
  - name: 🔍 Observability
    description: Outros métodos
  - name: 🗄️ Storage
    description: Métodos de armazenamento
externalDocs:
  description: Wappfy - WhatsApp HTTP API
  url: https://wappfy.com.br/
paths:
  /api/sendText:
    post:
      tags:
        - 📤 Chatting
      summary: Enviar uma mensagem de texto
      operationId: ChattingController_sendText
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MessageTextRequest'
              example:
                session: session
                chatId: 5511999999999@c.us
                text: Hello World!
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WAMessage'
      security:
        - api_key: []
components:
  schemas:
    MessageTextRequest:
      type: object
      example:
        session: my-session
        chatId: 5511999999999@c.us
        text: Olá, como vai?
        reply_to: null
        linkPreview: true
        linkPreviewHighQuality: false
      properties:
        chatId:
          type: string
          description: Identificador do chat (JID do WhatsApp)
          example: 5511999999999@c.us
        reply_to:
          type: string
          description: ID da mensagem à qual você deseja responder
          example: false_5511999999999@c.us_AAAAAAAAAAAAAAAAAAAA
        text:
          type: string
          description: Conteúdo da mensagem de texto
          default: Olá, como vai?
        linkPreview:
          type: boolean
          description: Ativar prévia de links automaticamente
          default: true
        linkPreviewHighQuality:
          type: boolean
          description: Prévia de links em alta qualidade
          default: false
        session:
          type: string
          example: my-session
          description: Nome da sessão (instanceName)
      required:
        - chatId
        - text
        - session
    WAMessage:
      type: object
      properties:
        id:
          type: string
          description: ID da mensagem
          example: false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA
        timestamp:
          type: number
          description: Timestamp Unix de quando a mensagem foi criada
          example: 1666943582
        from:
          type: string
          description: ID do chat para o qual esta mensagem foi enviada
          example: 5511999999999@c.us
        fromMe:
          type: boolean
          description: Indica se a mensagem foi enviada pelo usuário atual
        source:
          enum:
            - api
            - app
          type: string
          description: >-
            The device that sent the message - either API or APP. Available in
            events (webhooks/websockets) only and only "fromMe: true" messages.
          example: api
        to:
          type: string
          description: >-
            * ID for who this message is for.

            * If the message is sent by the current user, it will be the Chat to
            which the message is being sent.

            * If the message is sent by another user, it will be the ID for the
            current user.
          example: 5511999999999@c.us
        participant:
          type: string
          description: Para grupos - participante que enviou a mensagem
        body:
          type: string
          description: Conteúdo da mensagem
        hasMedia:
          type: boolean
          description: Indica se a mensagem possui mídia disponível para download
        media:
          description: Objeto de mídia da mensagem, se houver e foi baixada
          allOf:
            - $ref: '#/components/schemas/WAMedia'
        ack:
          enum:
            - -1
            - 0
            - 1
            - 2
            - 3
            - 4
          type: number
          description: Status de confirmação (ACK) da mensagem
        ackName:
          type: string
          description: Nome do status de confirmação da mensagem
        author:
          type: string
          description: >-
            Se a mensagem foi enviada para um grupo, este campo conterá o
            usuário que enviou a mensagem
        location:
          description: Informações de localização contidas na mensagem
          allOf:
            - $ref: '#/components/schemas/WALocation'
        vCards:
          description: Lista de vCards contidos na mensagem
          type: array
          items:
            type: string
        _data:
          type: object
          description: >-
            Mensagem em formato bruto do WhatsApp. Pode mudar a qualquer
            momento, use com cautela!
        replyTo:
          $ref: '#/components/schemas/ReplyToMessage'
      required:
        - id
        - timestamp
        - from
        - fromMe
        - source
        - to
        - participant
        - body
        - hasMedia
        - mediaUrl
        - ack
        - ackName
    WAMedia:
      type: object
      properties:
        url:
          type: string
          description: URL da mídia na mensagem, se houver
          example: >-
            http://localhost:3000/api/files/false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA.oga
        mimetype:
          type: string
          description: Tipo MIME da mídia na mensagem
          example: audio/jpeg
        filename:
          type: string
          description: Nome original do arquivo de mídia
          example: example.pdf
        s3:
          description: Atributos S3 da mídia se você estiver usando armazenamento S3
          allOf:
            - $ref: '#/components/schemas/S3MediaData'
        error:
          type: object
          description: Mensagem de erro ao baixar a mídia
          example: null
    WALocation:
      type: object
      properties:
        description:
          type: string
        latitude:
          type: string
        longitude:
          type: string
      required:
        - latitude
        - longitude
    ReplyToMessage:
      type: object
      properties:
        id:
          type: string
          description: ID da mensagem
          example: AAAAAAAAAAAAAAAAAAAA
        participant:
          type: string
          example: 5511999999999@c.us
        body:
          type: string
          example: Hello!
        _data:
          type: object
          description: Raw data from reply's message
      required:
        - id
    S3MediaData:
      type: object
      properties:
        Bucket:
          type: string
          description: Nome do bucket S3
          example: my-bucket
        Key:
          type: string
          description: Chave do objeto no bucket S3
          example: default/false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA.oga
      required:
        - Bucket
        - Key
  securitySchemes:
    api_key:
      type: apiKey
      in: header
      name: apikey
      description: Sua chave de API do Wappfy (obtenha em dash.wappfy.com.br)

````