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

# Send Message

> Envia un mensaje de WhatsApp al cliente. No se trata de una plantilla. Si ha pasado el tiempo permitido por WhatsApp (24 horas), el mensaje no llegara y se debera usar el servicio de plantillas.



## OpenAPI

````yaml POST /api/message
openapi: 3.1.0
info:
  title: Plazbot
  description: >-
    Documentacion completa de la API de Plazbot. Incluye todos los servicios
    para gestion de contactos, conversaciones, mensajes, oportunidades, tareas,
    plantillas, agentes de IA, usuarios y workspaces.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.plazbot.com
    description: Servidor de produccion de Plazbot
security:
  - bearerAuth: []
tags:
  - name: automation
    description: Servicios de automatizacion y nodos de IA
  - name: agent
    description: Servicios para gestion de Agentes de Inteligencia Artificial
  - name: contact
    description: Servicios para gestion de contactos del workspace
  - name: conversation
    description: Servicios para gestion de conversaciones y campanas
  - name: message
    description: Servicios para envio y gestion de mensajes
  - name: opportunity
    description: Servicios para gestion de oportunidades de negocio
  - name: task
    description: Servicios para gestion de tareas
  - name: template
    description: Servicios para gestion de plantillas de WhatsApp
  - name: user
    description: Servicios para gestion de usuarios y autenticacion
  - name: workspace
    description: Servicios para gestion de workspaces
paths:
  /api/message:
    post:
      tags:
        - message
      summary: Enviar Mensaje
      description: >-
        Envia un mensaje de WhatsApp al cliente. No se trata de una plantilla.
        Si ha pasado el tiempo permitido por WhatsApp (24 horas), el mensaje no
        llegara y se debera usar el servicio de plantillas.
      operationId: sendMessage
      parameters:
        - name: x-workspace-id
          in: header
          description: Identificador del workspace
          required: true
          schema:
            type: string
        - name: x-agent-id
          in: header
          description: Identificador del agente que envia el mensaje
          required: false
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                content:
                  type: string
                  description: Contenido del mensaje a enviar
                recipientPhone:
                  type: string
                  description: 'Numero de WhatsApp del destinatario (ej: 574787443997)'
                workspaceId:
                  type: string
                  description: Identificador del workspace
                conversationId:
                  type:
                    - string
                    - 'null'
                  description: ID de la conversacion
              required:
                - content
                - recipientPhone
                - workspaceId
      responses:
        '200':
          description: Mensaje enviado exitosamente
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: Indica si la operacion fue exitosa
                  code:
                    type: integer
                    description: Codigo HTTP de la respuesta
                  errorCode:
                    type:
                      - string
                      - 'null'
                    description: Codigo de error, null si no hay error
                  message:
                    type: string
                    description: Mensaje descriptivo del resultado
                  data:
                    type: object
                    properties:
                      contactId:
                        type: string
                        description: ID del contacto
                      message:
                        $ref: '#/components/schemas/Message'
                required:
                  - success
                  - code
                  - errorCode
                  - message
                  - data
        '400':
          description: Solicitud incorrecta - Datos invalidos o faltantes
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: No autorizado - Token Bearer requerido o invalido
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Recurso no encontrado
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Error interno del servidor
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    Message:
      type: object
      description: Mensaje enviado o recibido en una conversacion
      properties:
        id:
          type: string
          description: Identificador unico del mensaje
        messageWhatsappId:
          type:
            - string
            - 'null'
          description: ID del mensaje en WhatsApp
        contactId:
          type: string
          description: ID del contacto asociado
        content:
          type: string
          description: Contenido del mensaje
        workspaceId:
          type: string
          description: ID del workspace
        recipientPhone:
          type:
            - string
            - 'null'
          description: Telefono del destinatario
        externalReferenceId:
          type:
            - string
            - 'null'
          description: ID de referencia externa
        platformId:
          type:
            - string
            - 'null'
          description: ID de la plataforma
        answerAgentId:
          type:
            - string
            - 'null'
          description: ID del agente que respondio
        answerType:
          type:
            - string
            - 'null'
          description: Tipo de respuesta
        type:
          type:
            - string
            - 'null'
          description: Tipo de mensaje
        from:
          type:
            - string
            - 'null'
          description: Remitente del mensaje
        timestamp:
          type:
            - string
            - 'null'
          format: date-time
          description: Marca de tiempo del mensaje
        conversationId:
          type:
            - string
            - 'null'
          description: ID de la conversacion
        platformType:
          type:
            - string
            - 'null'
          description: Tipo de plataforma
        files:
          type: array
          items:
            type: string
          description: Archivos adjuntos del mensaje
    ErrorResponse:
      type: object
      description: Respuesta de error estandar de la API
      properties:
        success:
          type: boolean
          description: Siempre false en errores
        code:
          type: integer
          description: Codigo HTTP del error
        errorCode:
          type:
            - string
            - 'null'
          description: Codigo de error especifico
        message:
          type: string
          description: Mensaje descriptivo del error
      required:
        - success
        - code
        - message
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Token de autenticacion Bearer. Obtenga el token usando el endpoint
        /api/user/login

````