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

# Enviar un mensaje

> Envía un texto o una plantilla a una conversación (`conversation_id`) o a un teléfono (`to`).
El texto libre solo sale si el cliente escribió en las últimas 24 h (regla de WhatsApp); si no, usa una plantilla aprobada.
Para enviar un archivo usa `multipart/form-data` con el campo `file` y el destino en campos de texto.




## OpenAPI

````yaml /openapi.yaml post /messages
openapi: 3.1.0
info:
  title: API de Impulso Digital
  version: '1.0'
  description: >
    Conecta tu CRM, tu tienda o un asistente de IA a una cuenta de Impulso
    Digital: envía mensajes y plantillas por WhatsApp, lee conversaciones,
    maneja contactos y mensajes programados, y recibe avisos (webhooks) de lo
    que pasa en la cuenta.
  contact:
    name: Impulso Digital
    url: https://impulsodigital.app
    email: soporte@impulsodigital.app
servers:
  - url: https://api.impulsodigital.app/v1
    description: Producción
security:
  - llave: []
tags:
  - name: Cuenta
  - name: Mensajes
  - name: Conversaciones
  - name: Contactos
  - name: Plantillas
  - name: Programados
  - name: Avisos
paths:
  /messages:
    post:
      tags:
        - Mensajes
      summary: Enviar un mensaje
      description: >
        Envía un texto o una plantilla a una conversación (`conversation_id`) o
        a un teléfono (`to`).

        El texto libre solo sale si el cliente escribió en las últimas 24 h
        (regla de WhatsApp); si no, usa una plantilla aprobada.

        Para enviar un archivo usa `multipart/form-data` con el campo `file` y
        el destino en campos de texto.
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SendMessage'
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                conversation_id:
                  type: string
                to:
                  type: string
                number_id:
                  type: string
                pause_ai:
                  type: string
                  enum:
                    - 'true'
                    - 'false'
      responses:
        '201':
          description: Enviado
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                      conversation_id:
                        type: string
                      status:
                        const: sent
        '403':
          $ref: '#/components/responses/Error'
        '404':
          $ref: '#/components/responses/Error'
        '422':
          $ref: '#/components/responses/Error'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      description: >-
        Identificador tuyo para que un reintento no se procese dos veces (24 h,
        hasta 200 caracteres).
      schema:
        type: string
        maxLength: 200
  schemas:
    SendMessage:
      oneOf:
        - title: Texto
          type: object
          required:
            - type
            - text
          properties:
            type:
              const: text
            text:
              type: string
              maxLength: 4096
            reply_to:
              type: string
              description: Id de un mensaje de la conversación para responder citándolo.
            conversation_id:
              type: string
            to:
              type: string
              description: Teléfono con indicativo (crea el contacto si no existe).
              examples:
                - '573001234567'
            number_id:
              type: string
              description: Número de la cuenta por el que sale (si usas `to`).
            name:
              type: string
              description: Nombre del contacto nuevo (si usas `to`).
            pause_ai:
              type: boolean
              default: true
              description: 'false: la conversación sigue con el agente de IA.'
        - title: Plantilla
          type: object
          required:
            - type
            - template
          properties:
            type:
              const: template
            template:
              type: object
              properties:
                id:
                  type: string
                name:
                  type: string
                  examples:
                    - pedido_enviado
                variables:
                  type: object
                  additionalProperties:
                    type: string
                  examples:
                    - nombre: Ana
            conversation_id:
              type: string
            to:
              type: string
              examples:
                - '573001234567'
            number_id:
              type: string
            name:
              type: string
            pause_ai:
              type: boolean
              default: true
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              examples:
                - INSUFFICIENT_SCOPE
            message:
              type: string
              examples:
                - Esta llave no tiene el permiso «mensajes».
            details:
              type: object
              additionalProperties: true
  responses:
    Error:
      description: Error (ver `error.code`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    llave:
      type: http
      scheme: bearer
      description: >-
        Tu llave de API: `Authorization: Bearer imp_live_…`. También se acepta
        la cabecera `X-API-Key`.

````

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