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

# Enviar uma mensagem do WhatsApp

> Enviar uma mensagem do WhatsApp



## OpenAPI

````yaml pt-BR/openapi.json POST /v1/messages
openapi: 3.1.0
info:
  title: Watahub API
  version: 0.2.0
  description: >-
    API para clientes do Watahub, gateway multiempresa da WhatsApp Cloud API.
    Autentique cada requisição com `Authorization: Bearer <key>` ou `X-API-Key:
    <key>`. Os contratos próprios são fechados; os registros da Meta preservam
    campos adicionais. O proxy `/vN.N` preserva o corpo e o status da Meta;
    aceita a versão da rota, mas a ignora.
servers:
  - url: https://cloud.watahub.dev
security:
  - bearerApiKey: []
  - headerApiKey: []
tags:
  - name: Messages
  - name: Media
  - name: Templates
  - name: Graph-compatible proxy
    description: >-
      Compatibilidade com o Graph da Meta em três rotas. Retorna a resposta da
      Meta sem alterações.
  - name: Phones
    description: Telefones
  - name: Conversations
    description: Conversas
  - name: Connect
    description: Conexão
  - name: Customers
    description: Clientes
  - name: Webhooks
    description: Webhooks
  - name: Logs
    description: Registros
  - name: Health
    description: Status do serviço
  - name: Message templates
    description: >-
      Modelos por WABA em cache no gateway, sincronizados da Meta e necessários
      para campanhas.
  - name: Broadcasts
    description: >-
      Envia um modelo aprovado para até 500 destinatários; processado em fila e
      em segundo plano.
paths:
  /v1/messages:
    post:
      tags:
        - Messages
      summary: Enviar uma mensagem do WhatsApp
      description: >-
        O core transforma o corpo para `/messages` da Meta e retorna seu próprio
        formato, sem `wa_id` ou `message_status`. Um `MetaError` 5XX no envio
        indica `unknown_outcome`: a mensagem pode ter sido enviada.
      operationId: sendMessage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SendMessage'
      responses:
        '200':
          $ref: '#/components/responses/MessageSent'
        4XX:
          $ref: '#/components/responses/ClientError'
        5XX:
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    SendMessage:
      type: object
      required:
        - to
        - kind
      description: >-
        Exige o objeto correspondente a `kind` (`media` para image, audio,
        video, document e sticker).
      properties:
        to:
          type: string
          minLength: 1
          maxLength: 135
          description: Telefone do destinatário ou ID de usuário com escopo empresarial.
        phoneNumberId:
          type: string
          pattern: ^\d{1,32}$
        kind:
          type: string
          enum:
            - text
            - template
            - image
            - audio
            - video
            - document
            - reaction
            - interactive
            - location
            - contacts
            - sticker
        text:
          type: object
          required:
            - body
          properties:
            body:
              type: string
              minLength: 1
              maxLength: 4096
        template:
          type: object
          required:
            - name
            - language
          properties:
            name:
              type: string
              maxLength: 512
            language:
              type: object
              required:
                - code
              properties:
                code:
                  type: string
                  minLength: 2
                  maxLength: 16
            components:
              type: array
              items:
                type: object
                additionalProperties: true
        media:
          type: object
          description: >-
            Inclua id ou link. Áudio: sem caption/filename; voice somente em
            áudio. Vídeo: sem filename.
          properties:
            id:
              type: string
              pattern: ^\d{1,32}$
            link:
              type: string
              format: uri
            caption:
              type: string
              maxLength: 1024
            filename:
              type: string
              maxLength: 240
            voice:
              type: boolean
        reaction:
          type: object
          required:
            - messageId
            - emoji
          properties:
            messageId:
              type: string
              maxLength: 256
            emoji:
              type: string
              maxLength: 16
        location:
          type: object
          required:
            - latitude
            - longitude
          properties:
            latitude:
              type: number
              minimum: -90
              maximum: 90
            longitude:
              type: number
              minimum: -180
              maximum: 180
            name:
              type: string
              maxLength: 256
            address:
              type: string
              maxLength: 512
        contacts:
          type: array
          minItems: 1
          maxItems: 10
          items:
            type: object
            additionalProperties: true
            description: Cartão de contato do WhatsApp; exige name.formatted_name.
        interactive:
          type: object
          additionalProperties: true
          description: >-
            Objeto interactive da Meta. Valida flow, location_request_message,
            cta_url, product, product_list e order_details.
        replyToMessageId:
          type: string
          maxLength: 256
    SendMessageResult:
      type: object
      additionalProperties: false
      required:
        - success
        - messageId
        - recipient
        - phoneNumberId
      properties:
        success:
          const: true
        messageId:
          type: string
          description: >-
            `messages[0].id` da Meta (wamid). Vazio se a Meta não retornar
            nenhum.
        recipient:
          type: string
          description: >-
            `contacts[0].input` da Meta; caso contrário, telefone enviado sem
            `+` ou BSUID.
        phoneNumberId:
          type: string
          description: Número que enviou a mensagem.
    GatewayError:
      type: object
      description: >-
        Erro do gateway ou core. `error` é uma mensagem estável em inglês para
        desenvolvedores.
      additionalProperties: false
      required:
        - error
      properties:
        error:
          type: string
        fields:
          type: array
          items:
            type: string
          description: 'Com 400 `Invalid fields`: caminhos dos campos rejeitados.'
        requestId:
          type: string
          description: 'Com 500 `Operation unavailable`: ID para informar ao suporte.'
    ValidationError:
      type: object
      description: O core rejeitou um valor do corpo, rota, header ou consulta.
      additionalProperties: false
      required:
        - error
        - details
      properties:
        error:
          const: Validation failed
        details:
          type: object
          description: Mensagens por nome de campo.
          additionalProperties:
            type: array
            items:
              type: string
    MetaError:
      type: object
      description: >-
        A Meta falhou em `/v1`. Com erro da Meta: `code`, `subcode`, `type` nos
        envios e classificação do core. Se a Meta estiver inacessível ou
        retornar dados inutilizáveis, somente `message`, além de
        `unknown_outcome` nos envios.
      additionalProperties: false
      required:
        - error
      properties:
        error:
          type: object
          additionalProperties: false
          required:
            - message
          properties:
            message:
              type: string
            code:
              type: integer
              description: >-
                Código de erro da Meta; status HTTP se a Meta não fornecer
                código.
            subcode:
              type: integer
              description: '`error_subcode` da Meta.'
            type:
              type: string
              description: Tipo de erro da Meta. Somente nos envios.
            category:
              type: string
              enum:
                - auth
                - billing
                - rate_limit
                - meta_server
                - unknown
                - unknown_outcome
            retryable:
              type: boolean
            action:
              type: string
              description: Próxima ação, em inglês.
  responses:
    MessageSent:
      description: A Meta aceitou a mensagem.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SendMessageResult'
    ClientError:
      description: >-
        Rejeitado pelo gateway (`GatewayError`), pela validação do core
        (`ValidationError`, 422) ou pela Meta (`MetaError`, com seu status
        HTTP).
      content:
        application/json:
          schema:
            anyOf:
              - $ref: '#/components/schemas/GatewayError'
              - $ref: '#/components/schemas/ValidationError'
              - $ref: '#/components/schemas/MetaError'
    ServerError:
      description: >-
        `GatewayError` por falha do gateway (500 com `requestId`, 503 por falta
        de configuração); `MetaError` por 5XX da Meta, falha de conexão (502) ou
        timeout (504).
      content:
        application/json:
          schema:
            anyOf:
              - $ref: '#/components/schemas/GatewayError'
              - $ref: '#/components/schemas/MetaError'
  securitySchemes:
    bearerApiKey:
      type: http
      scheme: bearer
      description: Chave de API da conta.
    headerApiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: Chave de API da conta.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.