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

# Enviar un mensaje

> Envía un mensaje de WhatsApp a un teléfono (`to`) o a un usuario sin teléfono (`recipient`, su BSUID) por un canal. El body es el de la Cloud API de WhatsApp más `channel_id`: un `type` y un objeto con ese mismo nombre. Si el número es nuevo, Gluu crea el contacto y la conversación.

Fuera de la ventana de 24 horas solo se pueden mandar plantillas. Gluu revisa todo antes de crear nada: si algo falla responde `422` y no deja nada a medias.

Requiere una clave `full` o `send_only`. Acepta `Idempotency-Key`.



## OpenAPI

````yaml /openapi.yaml post /messages
openapi: 3.1.0
info:
  title: API de Gluu
  version: '1.0'
  description: >-
    Manda y recibe mensajes de WhatsApp desde tu sistema, arma tu propio inbox
    con las conversaciones y los contactos del workspace, y recibe webhooks
    cuando algo cambia.
servers:
  - url: https://api.wegluu.com/v1
    description: Producción
security:
  - apiKey: []
tags:
  - name: Mensajes
    description: Envía cualquier tipo de mensaje de WhatsApp y consulta su estado.
  - name: Archivos
    description: Sube archivos o impórtalos desde una URL para enviarlos.
  - name: Conversaciones
    description: La lista de chats, su historial, respuestas y lectura.
  - name: Contactos
    description: Los contactos del workspace y su identidad de WhatsApp.
  - name: Equipo
    description: Los usuarios del workspace.
  - name: Canales
    description: Los canales conectados al workspace.
  - name: Plantillas
    description: Las plantillas de WhatsApp de cada canal.
  - name: Webhooks
    description: Eventos que Gluu manda a tu servidor.
paths:
  /messages:
    post:
      tags:
        - Mensajes
      summary: Enviar un mensaje
      description: >-
        Envía un mensaje de WhatsApp a un teléfono (`to`) o a un usuario sin
        teléfono (`recipient`, su BSUID) por un canal. El body es el de la Cloud
        API de WhatsApp más `channel_id`: un `type` y un objeto con ese mismo
        nombre. Si el número es nuevo, Gluu crea el contacto y la conversación.


        Fuera de la ventana de 24 horas solo se pueden mandar plantillas. Gluu
        revisa todo antes de crear nada: si algo falla responde `422` y no deja
        nada a medias.


        Requiere una clave `full` o `send_only`. Acepta `Idempotency-Key`.
      operationId: sendMessage
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SendMessageRequest'
            examples:
              text:
                summary: Texto
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: text
                  text:
                    body: Hola Ana, tu pedido ya salió.
              text_bsuid:
                summary: Texto a un usuario sin teléfono
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  recipient: MX.13491208655302741918
                  type: text
                  text:
                    body: Hola, ¿en qué te ayudamos?
              reply_quoting:
                summary: Respuesta citando un mensaje
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: text
                  text:
                    body: Sí, ese mismo
                  context:
                    message_id: wamid.HBgNNTIxNTUxMjM0NTY3OBUCABEYEjQ
              image_link:
                summary: Imagen por link
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: image
                  image:
                    link: https://cdn.example.com/catalogo/zapatilla-roja.jpg
                    caption: Te paso la foto
              image_id:
                summary: Imagen subida con POST /media
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: image
                  image:
                    id: 0193a1e0-5c6d-7e8f-9a0b-1c2d3e4f5a6b
              video:
                summary: Video
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: video
                  video:
                    link: https://cdn.example.com/videos/instalacion.mp4
                    caption: Así se instala
              voice_note:
                summary: Nota de voz
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: audio
                  audio:
                    link: https://cdn.example.com/audios/bienvenida.mp3
                    voice: true
              document:
                summary: Documento
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: document
                  document:
                    link: https://facturas.example.com/F-4821.pdf
                    filename: Factura F-4821.pdf
                    caption: Tu factura de diciembre
              sticker:
                summary: Sticker
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: sticker
                  sticker:
                    link: https://cdn.example.com/stickers/gracias.webp
              location:
                summary: Ubicación
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: location
                  location:
                    latitude: 19.4326
                    longitude: -99.1332
                    name: Sucursal Centro
                    address: Av. Juárez 10, Centro, CDMX
              contacts:
                summary: Tarjeta de contacto
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: contacts
                  contacts:
                    - name:
                        formatted_name: Soporte Gluu
                      phones:
                        - phone: '+5215598765432'
                          type: WORK
                          wa_id: '5215598765432'
              buttons:
                summary: Botones de respuesta
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: interactive
                  interactive:
                    type: button
                    body:
                      text: ¿Confirmas tu cita del jueves a las 10:00?
                    action:
                      buttons:
                        - type: reply
                          reply:
                            id: confirmar
                            title: Confirmo
                        - type: reply
                          reply:
                            id: reagendar
                            title: Cambiar horario
              list:
                summary: Lista
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: interactive
                  interactive:
                    type: list
                    body:
                      text: ¿Qué sucursal te queda mejor?
                    action:
                      button: Ver sucursales
                      sections:
                        - title: CDMX
                          rows:
                            - id: centro
                              title: Centro
                              description: Av. Juárez 10
                            - id: polanco
                              title: Polanco
                              description: Masaryk 200
              cta_url:
                summary: Botón con enlace
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: interactive
                  interactive:
                    type: cta_url
                    body:
                      text: Tu pedido
                    action:
                      name: cta_url
                      parameters:
                        display_text: Seguir envío
                        url: https://envios.example.com/4821
              flow:
                summary: WhatsApp Flow
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: interactive
                  interactive:
                    type: flow
                    body:
                      text: Completa tus datos para la cotización
                    action:
                      name: flow
                      parameters:
                        flow_message_version: '3'
                        flow_id: '1234567890123456'
                        flow_cta: Completar
                        flow_action: navigate
                        flow_action_payload:
                          screen: DATOS
              template_variables:
                summary: Plantilla con variables
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: template
                  template:
                    name: confirmacion_pedido
                    language: es_MX
                    variables:
                      '1': Ana
                      '2': '#4821'
              template_header_media:
                summary: Plantilla con documento en el encabezado
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: template
                  template:
                    name: factura_lista
                    language: es_MX
                    variables:
                      '1': Ana
                    header_media:
                      url: https://facturas.example.com/F-4821.pdf
                      filename: Factura F-4821.pdf
              template_components:
                summary: Plantilla con components de WhatsApp
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: template
                  template:
                    name: oferta_cupon
                    language:
                      code: es_MX
                    components:
                      - type: body
                        parameters:
                          - type: text
                            text: Ana
                      - type: button
                        sub_type: copy_code
                        index: '0'
                        parameters:
                          - type: coupon_code
                            coupon_code: ANA10
              reaction:
                summary: Reacción
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: reaction
                  reaction:
                    message_id: wamid.HBgNNTIxNTUxMjM0NTY3OBUCABEYEjQ
                    emoji: 👍
              legacy:
                summary: Forma anterior (sigue funcionando)
                value:
                  channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                  to: '+5215512345678'
                  type: document
                  media:
                    url: https://example.com/catalogo.pdf
                    filename: catalogo.pdf
                    caption: Nuestro catálogo
      responses:
        '202':
          $ref: '#/components/responses/MessageAccepted'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/IdempotencyInProgress'
        '415':
          $ref: '#/components/responses/UnsupportedMediaType'
        '422':
          $ref: '#/components/responses/SendRejected'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      description: >-
        Identificador único de este envío, de 1 a 255 caracteres. Si repites la
        llamada con la misma clave y el mismo body dentro de 24 horas, Gluu
        devuelve la respuesta original sin mandar otro mensaje.
      schema:
        type: string
        minLength: 1
        maxLength: 255
  schemas:
    SendMessageRequest:
      description: El destinatario y el mensaje. Es el body de `POST /messages`.
      allOf:
        - $ref: '#/components/schemas/Recipient'
        - $ref: '#/components/schemas/MessageContent'
    Recipient:
      type: object
      required:
        - channel_id
      properties:
        channel_id:
          type: string
          format: uuid
          description: >-
            Canal de WhatsApp conectado por el que sale el mensaje (de `GET
            /channels`).
        to:
          type: string
          minLength: 6
          maxLength: 32
          description: >-
            Teléfono en formato internacional, por ejemplo `+5215512345678`. Si
            no hay contacto con ese número, Gluu lo crea. Manda `to` o
            `recipient`; si mandas los dos, gana `to`.
          example: '+5215512345678'
        recipient:
          type: string
          minLength: 4
          maxLength: 128
          description: >-
            BSUID o BSUID padre del contacto, para quien no comparte su
            teléfono. Solo sirve con contactos que ya escribieron por ese canal.
          example: MX.13491208655302741918
    MessageContent:
      description: >-
        El mensaje, sin destinatario. Es el body de `POST
        /conversations/{id}/messages`.
      oneOf:
        - $ref: '#/components/schemas/TextContent'
        - $ref: '#/components/schemas/ImageContent'
        - $ref: '#/components/schemas/VideoContent'
        - $ref: '#/components/schemas/AudioContent'
        - $ref: '#/components/schemas/DocumentContent'
        - $ref: '#/components/schemas/StickerContent'
        - $ref: '#/components/schemas/LocationContent'
        - $ref: '#/components/schemas/ContactsContent'
        - $ref: '#/components/schemas/InteractiveContent'
        - $ref: '#/components/schemas/TemplateContent'
        - $ref: '#/components/schemas/ReactionContent'
    MessageResponse:
      type: object
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/Message'
    Error:
      type: object
      required:
        - code
        - message
        - request_id
      properties:
        code:
          type: string
          description: Código estable del error, en minúsculas. Programa contra este campo.
        message:
          type: string
          description: Explicación para personas. Puede cambiar.
        request_id:
          type: string
          description: Id de la llamada. Compártelo si escribes a soporte.
        errors:
          type: array
          description: Presente en `validation_error`, con un elemento por campo inválido.
          items:
            type: object
            required:
              - field
              - message
            properties:
              field:
                type: string
              message:
                type: string
        details:
          type: object
          additionalProperties: true
          description: >-
            Datos extra de algunos errores, por ejemplo `missing` en
            `template_variable_missing`.
    TextContent:
      title: Texto
      allOf:
        - $ref: '#/components/schemas/MessageCommon'
        - type: object
          required:
            - type
            - text
          properties:
            type:
              type: string
              const: text
            text:
              oneOf:
                - type: object
                  required:
                    - body
                  properties:
                    body:
                      type: string
                      minLength: 1
                      maxLength: 4096
                      description: >-
                        Texto, con el formato de WhatsApp (`*negrita*`,
                        `_cursiva_`, `~tachado~`).
                    preview_url:
                      type: boolean
                      description: >-
                        Se acepta pero se ignora. La vista previa de enlaces
                        siempre está activa.
                - type: string
                  minLength: 1
                  maxLength: 4096
                  deprecated: true
                  description: Forma anterior.
    ImageContent:
      title: Imagen
      allOf:
        - $ref: '#/components/schemas/MessageCommon'
        - type: object
          required:
            - type
          description: Manda `image` o, con la forma anterior, `media`.
          properties:
            type:
              type: string
              const: image
            image:
              allOf:
                - $ref: '#/components/schemas/MediaSource'
                - type: object
                  description: JPG o PNG de hasta 5 MB.
                  properties:
                    caption:
                      type: string
                      maxLength: 1024
            media:
              $ref: '#/components/schemas/LegacyMedia'
    VideoContent:
      title: Video
      allOf:
        - $ref: '#/components/schemas/MessageCommon'
        - type: object
          required:
            - type
          properties:
            type:
              type: string
              const: video
            video:
              allOf:
                - $ref: '#/components/schemas/MediaSource'
                - type: object
                  description: MP4 o 3GP de hasta 16 MB (video H.264, audio AAC).
                  properties:
                    caption:
                      type: string
                      maxLength: 1024
            media:
              $ref: '#/components/schemas/LegacyMedia'
    AudioContent:
      title: Audio o nota de voz
      allOf:
        - $ref: '#/components/schemas/MessageCommon'
        - type: object
          required:
            - type
          properties:
            type:
              type: string
              const: audio
            audio:
              allOf:
                - $ref: '#/components/schemas/MediaSource'
                - type: object
                  description: >-
                    AAC, AMR, MP3, M4A, OGG, WEBM o WAV de hasta 16 MB. Gluu lo
                    convierte si hace falta.
                  properties:
                    voice:
                      type: boolean
                      description: >-
                        `true` lo manda como nota de voz. Sin él, llega como
                        archivo de audio.
            media:
              $ref: '#/components/schemas/LegacyMedia'
    DocumentContent:
      title: Documento
      allOf:
        - $ref: '#/components/schemas/MessageCommon'
        - type: object
          required:
            - type
          properties:
            type:
              type: string
              const: document
            document:
              allOf:
                - $ref: '#/components/schemas/MediaSource'
                - type: object
                  description: PDF, TXT, DOC, DOCX, XLS, XLSX, PPT o PPTX de hasta 100 MB.
                  properties:
                    caption:
                      type: string
                      maxLength: 1024
                    filename:
                      type: string
                      maxLength: 240
                      description: >-
                        El nombre que ve el contacto. Si no lo mandas, se usa el
                        del archivo.
            media:
              $ref: '#/components/schemas/LegacyMedia'
    StickerContent:
      title: Sticker
      allOf:
        - $ref: '#/components/schemas/MessageCommon'
        - type: object
          required:
            - type
            - sticker
          properties:
            type:
              type: string
              const: sticker
            sticker:
              allOf:
                - $ref: '#/components/schemas/MediaSource'
                - type: object
                  description: WEBP de hasta 500 KB.
    LocationContent:
      title: Ubicación
      allOf:
        - $ref: '#/components/schemas/MessageCommon'
        - type: object
          required:
            - type
            - location
          properties:
            type:
              type: string
              const: location
            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: 1000
                address:
                  type: string
                  maxLength: 1000
    ContactsContent:
      title: Tarjetas de contacto
      allOf:
        - $ref: '#/components/schemas/MessageCommon'
        - type: object
          required:
            - type
            - contacts
          properties:
            type:
              type: string
              const: contacts
            contacts:
              type: array
              minItems: 1
              maxItems: 20
              description: >-
                Tarjetas con la forma de WhatsApp. Solo `name.formatted_name` es
                obligatorio; `phones`, `emails`, `addresses`, `org`, `urls` y
                `birthday` pasan tal cual. Agrega `wa_id` a cada teléfono para
                que la tarjeta muestre el botón de enviar mensaje.
              items:
                type: object
                required:
                  - name
                additionalProperties: true
                properties:
                  name:
                    type: object
                    required:
                      - formatted_name
                    additionalProperties: true
                    properties:
                      formatted_name:
                        type: string
                        maxLength: 200
                      first_name:
                        type: string
                      last_name:
                        type: string
                  phones:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                      properties:
                        phone:
                          type: string
                        type:
                          type: string
                        wa_id:
                          type: string
    InteractiveContent:
      title: Interactivo
      allOf:
        - $ref: '#/components/schemas/MessageCommon'
        - type: object
          required:
            - type
            - interactive
          properties:
            type:
              type: string
              const: interactive
            interactive:
              type: object
              required:
                - type
              additionalProperties: true
              description: >-
                Cualquier interactivo de WhatsApp, que Gluu envía tal cual:
                `button`, `list`, `cta_url`, `flow`, `carousel`,
                `location_request_message`, `request_contact_info`, `product`,
                `product_list`, `catalog_message`, `order_details`,
                `order_status`, `address_message`, `call_permission_request` y
                `voice_call`. WhatsApp valida el detalle: un interactivo mal
                armado sale como `failed` con el motivo en `error`.
              properties:
                type:
                  type: string
                  maxLength: 64
                header:
                  type: object
                  additionalProperties: true
                body:
                  type: object
                  additionalProperties: true
                  properties:
                    text:
                      type: string
                      maxLength: 4096
                footer:
                  type: object
                  additionalProperties: true
                action:
                  type: object
                  additionalProperties: true
    TemplateContent:
      title: Plantilla
      allOf:
        - $ref: '#/components/schemas/MessageCommon'
        - type: object
          required:
            - type
            - template
          properties:
            type:
              type: string
              const: template
            template:
              type: object
              required:
                - name
                - language
              description: Llena las variables con `variables` o con `components`.
              properties:
                name:
                  type: string
                  maxLength: 512
                language:
                  description: Idioma exacto de la plantilla, como en `GET /templates`.
                  oneOf:
                    - type: string
                      example: es_MX
                    - type: object
                      required:
                        - code
                      properties:
                        code:
                          type: string
                variables:
                  type: object
                  additionalProperties:
                    type: string
                    maxLength: 1024
                  description: >-
                    Ayuda de Gluu. La clave es el número o el nombre de la
                    variable (`1`, `nombre`) o la clave completa (`body:1`,
                    `header:nombre`, `button:0:1`). Gluu revisa que no falte
                    ninguna. Llena el encabezado de texto, el cuerpo y las URLs
                    de los botones.
                  example:
                    '1': Ana
                    '2': '#4821'
                header_media:
                  type: object
                  required:
                    - url
                  description: >-
                    Archivo del encabezado si la plantilla tiene `header_format`
                    `IMAGE`, `VIDEO` o `DOCUMENT`. Obligatorio con `variables`.
                    WhatsApp lo descarga de la URL al enviar.
                  properties:
                    url:
                      type: string
                      format: uri
                    filename:
                      type: string
                      maxLength: 240
                      description: Solo para documentos.
                components:
                  type: array
                  maxItems: 20
                  items:
                    type: object
                    additionalProperties: true
                  description: >-
                    Los `components` de WhatsApp con los parámetros, que Gluu
                    envía tal cual y WhatsApp valida. Sirve para lo que
                    `variables` no cubre: payloads de respuesta rápida, códigos
                    para copiar, monedas y fechas.
    ReactionContent:
      title: Reacción
      allOf:
        - $ref: '#/components/schemas/MessageCommon'
        - type: object
          required:
            - type
            - reaction
          properties:
            type:
              type: string
              const: reaction
            reaction:
              type: object
              required:
                - message_id
                - emoji
              properties:
                message_id:
                  type: string
                  maxLength: 256
                  description: >-
                    Id de Gluu o `platform_message_id` del mensaje. Del mismo
                    chat y ya enviado.
                emoji:
                  type: string
                  maxLength: 16
                  description: Un emoji. Vacío quita tu reacción.
    Message:
      type: object
      description: >-
        Un mensaje de WhatsApp, entrante o saliente, con la forma de los
        mensajes de WhatsApp: `type` y un objeto con ese mismo nombre, más los
        campos que agrega Gluu.
      required:
        - id
        - platform
        - platform_message_id
        - timestamp
        - type
        - direction
        - status
        - origin
        - context
        - content
        - media
        - transcript
        - gluu
      properties:
        id:
          type: string
          format: uuid
          description: Id de Gluu del mensaje.
        platform:
          type: string
          const: whatsapp
        platform_message_id:
          type:
            - string
            - 'null'
          description: Id de WhatsApp (`wamid`). `null` mientras un saliente está en cola.
        timestamp:
          type: string
          description: Segundos Unix, como texto.
          example: '1796396531'
        type:
          type: string
          enum:
            - text
            - image
            - video
            - audio
            - document
            - sticker
            - location
            - contacts
            - interactive
            - template
            - reaction
            - system
            - unsupported
        direction:
          type: string
          enum:
            - inbound
            - outbound
        status:
          type: string
          enum:
            - received
            - pending
            - processing
            - sent
            - delivered
            - read
            - failed
          description: En entrantes, siempre `received`.
        origin:
          type: string
          enum:
            - contact
            - inbox
            - api
            - agent
            - campaign
            - automation
            - business_app
          description: >-
            Quién lo originó: `contact` (entrantes), `inbox` (una persona en
            Gluu), `api`, `agent` (agente de IA), `campaign`, `automation`
            (workflows y recordatorios) o `business_app` (la app de WhatsApp
            Business, en coexistencia).
        from:
          type:
            - string
            - 'null'
          description: >-
            Solo en entrantes. Teléfono del contacto, solo dígitos. `null` si no
            lo comparte.
        from_user_id:
          type:
            - string
            - 'null'
          description: Solo en entrantes. BSUID del contacto.
        from_parent_user_id:
          type:
            - string
            - 'null'
          description: Solo en entrantes. BSUID padre del contacto.
        to:
          type:
            - string
            - 'null'
          description: Solo en salientes. Teléfono del contacto, solo dígitos.
        to_user_id:
          type:
            - string
            - 'null'
          description: Solo en salientes. BSUID del contacto.
        to_parent_user_id:
          type:
            - string
            - 'null'
          description: Solo en salientes. BSUID padre del contacto.
        username:
          type:
            - string
            - 'null'
          description: >-
            Usuario de WhatsApp del contacto. Puede cambiar; no lo uses para
            identificarlo.
        profile_name:
          type:
            - string
            - 'null'
          description: Nombre del contacto en WhatsApp o en Gluu.
        text:
          type: object
          properties:
            body:
              type: string
        image:
          $ref: '#/components/schemas/MessageMediaInfo'
        video:
          $ref: '#/components/schemas/MessageMediaInfo'
        document:
          $ref: '#/components/schemas/MessageMediaInfo'
        audio:
          type: object
          properties:
            mime_type:
              type:
                - string
                - 'null'
            voice:
              type: boolean
              description: '`true` si es nota de voz.'
        sticker:
          type: object
          properties:
            mime_type:
              type:
                - string
                - 'null'
        location:
          type: object
          properties:
            latitude:
              type:
                - number
                - 'null'
            longitude:
              type:
                - number
                - 'null'
            name:
              type:
                - string
                - 'null'
            address:
              type:
                - string
                - 'null'
        contacts:
          type: array
          items:
            type: object
            properties:
              name:
                type:
                  - string
                  - 'null'
              phones:
                type: array
                items:
                  type: string
        reaction:
          type: object
          properties:
            emoji:
              type:
                - string
                - 'null'
              description: Vacío o `null` si se quitó la reacción.
            message_id:
              type:
                - string
                - 'null'
              description: '`platform_message_id` del mensaje al que reacciona.'
        template:
          type: object
          properties:
            name:
              type:
                - string
                - 'null'
            language:
              type:
                - string
                - 'null'
        interactive:
          type: object
          additionalProperties: true
          description: >-
            En una respuesta: `{ type: "button_reply", button_reply: { id, title
            } }`, `{ type: "list_reply", list_reply: { id, title, description }
            }` o `{ type: "nfm_reply", nfm_reply: { flow_id, flow_name, answers:
            [{ key, label, value }] } }`. Enviado por la API: el objeto que
            mandaste, tal cual. Enviado desde Gluu: `{ type, header, body,
            footer }` más `buttons`, `button_text` y `sections`, `display_text`
            y `url`, o `flow`.
        context:
          type:
            - object
            - 'null'
          description: El mensaje citado. `id` es `null` si no está en Gluu.
          properties:
            id:
              type:
                - string
                - 'null'
              format: uuid
            platform_message_id:
              type:
                - string
                - 'null'
        content:
          type:
            - string
            - 'null'
          description: Texto plano listo para mostrar.
        media:
          type:
            - object
            - 'null'
          description: El archivo del mensaje, si lo hay.
          properties:
            url:
              type:
                - string
                - 'null'
              description: Enlace firmado para descargarlo. Vence a los 7 días.
            filename:
              type:
                - string
                - 'null'
            content_type:
              type:
                - string
                - 'null'
            byte_size:
              type:
                - integer
                - 'null'
        transcript:
          type:
            - object
            - 'null'
          description: Transcripción de una nota de voz.
          properties:
            text:
              type: string
        statuses:
          type: array
          description: Solo en salientes. Historial de estados.
          items:
            type: object
            properties:
              status:
                type: string
                enum:
                  - sent
                  - delivered
                  - read
                  - failed
              timestamp:
                type: string
                description: Segundos Unix, como texto.
        error:
          type:
            - object
            - 'null'
          description: Solo en salientes. Por qué falló, si `status` es `failed`.
          properties:
            code:
              type:
                - string
                - 'null'
              description: >-
                Código de WhatsApp (por ejemplo `131047`) o de Gluu (en
                mayúsculas).
            message:
              type:
                - string
                - 'null'
        sender:
          type:
            - object
            - 'null'
          description: >-
            Solo en salientes. Quién lo mandó: una persona (`user`) o una clave
            de API (`api_key`). `null` para agentes, campañas y
            automatizaciones.
          properties:
            type:
              type: string
              enum:
                - user
                - api_key
            id:
              type:
                - string
                - 'null'
            name:
              type:
                - string
                - 'null'
        gluu:
          type: object
          required:
            - channel_id
            - contact_id
            - conversation_id
          properties:
            channel_id:
              type: string
              format: uuid
            contact_id:
              type:
                - string
                - 'null'
              format: uuid
            conversation_id:
              type: string
              format: uuid
    MessageCommon:
      type: object
      properties:
        context:
          type: object
          description: >-
            Para que el mensaje salga como respuesta citada. No aplica a
            `reaction`.
          required:
            - message_id
          properties:
            message_id:
              type: string
              maxLength: 256
              description: >-
                Id de Gluu o `platform_message_id` del mensaje citado. Tiene que
                ser del mismo chat y estar enviado.
        messaging_product:
          type: string
          enum:
            - whatsapp
          description: >-
            Se acepta para poder pegar un body de WhatsApp tal cual. No cambia
            nada.
        recipient_type:
          type: string
          enum:
            - individual
          description: >-
            Se acepta para poder pegar un body de WhatsApp tal cual. No cambia
            nada.
    MediaSource:
      type: object
      description: El archivo va por `link` o por `id`, nunca los dos.
      properties:
        link:
          type: string
          format: uri
          maxLength: 2048
          description: >-
            URL pública `https://` del archivo. Gluu lo descarga, lo valida y lo
            guarda antes de enviar (30 segundos como máximo, hasta 3
            redirecciones, sin redes privadas).
        id:
          type: string
          maxLength: 64
          description: >-
            Id de un archivo subido con `POST /media`, de menos de 30 días y del
            mismo tipo.
    LegacyMedia:
      type: object
      description: >-
        Forma anterior de mandar un archivo. Sigue funcionando; pasa por la
        misma validación que `link`.
      deprecated: true
      required:
        - url
      properties:
        url:
          type: string
          format: uri
        filename:
          type: string
          maxLength: 240
        mime_type:
          type: string
          maxLength: 120
        caption:
          type: string
          maxLength: 1024
    MessageMediaInfo:
      type: object
      properties:
        caption:
          type:
            - string
            - 'null'
        mime_type:
          type:
            - string
            - 'null'
        filename:
          type:
            - string
            - 'null'
          description: Solo en documentos.
  responses:
    MessageAccepted:
      description: >-
        Gluu aceptó el mensaje y lo puso en cola, con `status: "pending"`. No
        quiere decir que WhatsApp lo haya entregado: síguelo con los webhooks o
        con `GET /messages/{id}`.
      headers:
        Gluu-Request-Id:
          $ref: '#/components/headers/Gluu-Request-Id'
        Idempotent-Replayed:
          $ref: '#/components/headers/Idempotent-Replayed'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MessageResponse'
          example:
            data:
              id: 0193a1c8-0e2f-7a55-b1d3-9c4e7f2a6b08
              platform: whatsapp
              platform_message_id: null
              timestamp: '1796396531'
              type: text
              direction: outbound
              status: pending
              origin: api
              to: '5215512345678'
              to_user_id: null
              to_parent_user_id: null
              username: null
              profile_name: Ana Gómez
              text:
                body: Hola Ana, tu pedido ya salió.
              context: null
              content: Hola Ana, tu pedido ya salió.
              media: null
              transcript: null
              statuses: []
              error: null
              sender:
                type: api_key
                id: 0193a0aa-1b2c-7d3e-8f4a-5b6c7d8e9f0a
                name: ERP
              gluu:
                channel_id: 0193a1c2-7b4e-7c1a-9f3e-2d5b8a6c4e10
                contact_id: 0193a1c7-e4b2-7f13-8c5d-1a2b3c4d5e6f
                conversation_id: 0193a1c7-f3a1-7e90-a2b4-5d6c8e1f3a27
    BadRequest:
      description: >-
        El body no es JSON válido (`invalid_json`), el form no se pudo leer
        (`invalid_multipart`) o el header `Idempotency-Key` no es válido
        (`invalid_idempotency_key`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: invalid_json
            message: El body no es JSON válido.
            request_id: 0193a1c9-51de-7d02-8a44-6f0e2b7c9d31
    Unauthorized:
      description: Falta la clave de API, no existe o fue revocada (`unauthorized`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: unauthorized
            message: La clave de API no existe o fue revocada.
            request_id: 0193a1c9-51de-7d02-8a44-6f0e2b7c9d31
    Forbidden:
      description: La clave no tiene permiso para esta operación (`forbidden`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: forbidden
            message: Esta clave de API no tiene permiso para mandar mensajes.
            request_id: 0193a1c9-51de-7d02-8a44-6f0e2b7c9d31
    IdempotencyInProgress:
      description: >-
        Otra llamada con la misma `Idempotency-Key` todavía no terminó
        (`idempotency_request_in_progress`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: idempotency_request_in_progress
            message: >-
              Otra llamada con esta Idempotency-Key todavía no terminó.
              Reintenta en unos segundos.
            request_id: 0193a1c9-51de-7d02-8a44-6f0e2b7c9d31
    UnsupportedMediaType:
      description: El body no se mandó como `application/json` (`unsupported_media_type`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: unsupported_media_type
            message: >-
              Manda el body como JSON con el header Content-Type:
              application/json.
            request_id: 0193a1c9-51de-7d02-8a44-6f0e2b7c9d31
    SendRejected:
      description: >-
        El envío no se hizo y no se creó nada. `code` dice por qué:
        `validation_error`, `channel_not_found`, `unsupported_channel`,
        `channel_disconnected`, `invalid_phone`, `recipient_not_found`,
        `referenced_message_not_found`, `referenced_message_other_chat`,
        `referenced_message_not_sent`, `outside_service_window`,
        `template_not_found`, `template_not_approved`,
        `template_variable_missing`, `template_header_media_required`,
        `media_not_found`, `media_expired`, `media_type_mismatch`,
        `media_format_unsupported`, `media_too_large`, `media_empty`,
        `media_download_failed` o `idempotency_key_reused`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            validation:
              summary: Campos inválidos
              value:
                code: validation_error
                message: Hay campos inválidos. Revisa `errors`.
                request_id: 0193a1c9-51de-7d02-8a44-6f0e2b7c9d31
                errors:
                  - field: to
                    message: Manda `to` (teléfono) o `recipient` (BSUID).
            window:
              summary: Fuera de la ventana de 24 horas
              value:
                code: outside_service_window
                message: >-
                  Pasaron más de 24 horas desde el último mensaje del contacto
                  (o nunca escribió). Usa una plantilla aprobada.
                request_id: 0193a1c9-51de-7d02-8a44-6f0e2b7c9d31
                details:
                  window_expires_at: '2026-12-04T15:02:11.000Z'
            variables:
              summary: Faltan variables de la plantilla
              value:
                code: template_variable_missing
                message: >-
                  Faltan valores para algunas variables de la plantilla. Revisa
                  `details.missing`.
                request_id: 0193a1c9-51de-7d02-8a44-6f0e2b7c9d31
                details:
                  missing:
                    - body:2
            recipient:
              summary: BSUID desconocido
              value:
                code: recipient_not_found
                message: >-
                  No hay un contacto con ese BSUID en este canal. A un BSUID
                  solo se le puede escribir si el contacto escribió antes.
                request_id: 0193a1c9-51de-7d02-8a44-6f0e2b7c9d31
            media_mismatch:
              summary: Archivo de otro tipo
              value:
                code: media_type_mismatch
                message: >-
                  El archivo es document y el mensaje es image. Para image: JPG
                  o PNG de hasta 5 MB.
                request_id: 0193a1c9-51de-7d02-8a44-6f0e2b7c9d31
                details:
                  media_type: document
                  mime_type: application/pdf
    RateLimited:
      description: >-
        Superaste el límite de 120 llamadas por minuto con esta clave
        (`rate_limited`).
      headers:
        Retry-After:
          $ref: '#/components/headers/Retry-After'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: rate_limited
            message: Superaste el límite de 120 llamadas por minuto con esta clave.
            request_id: 0193a1c9-51de-7d02-8a44-6f0e2b7c9d31
  headers:
    Gluu-Request-Id:
      description: >-
        Id de la llamada. Es el mismo `request_id` de los errores y del registro
        de la clave.
      schema:
        type: string
    Idempotent-Replayed:
      description: >-
        Vale `true` cuando la respuesta es la repetición de una llamada anterior
        con la misma `Idempotency-Key`.
      schema:
        type: string
    Retry-After:
      description: Segundos que conviene esperar antes de reintentar.
      schema:
        type: integer
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: >-
        Clave de API del workspace, con el formato `gluu_live_…`. Créala en
        Configuración → Desarrolladores. Permisos: `full` (todo), `send_only`
        (leer, enviar y subir archivos) y `read_only` (solo leer).

````

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