Skip to main content

POST /messages

Enviar un mensaje de WhatsApp. Soporta texto, imagen, video, audio, documento, template e interactivos. Scope requerido: messages:write

Body

CampoTipoRequeridoDescripción
phoneNumberIdstring (UUID)ID del canal (de GET /channels)
tostringNúmero del destinatario en formato E.164
typestringtext, image, video, audio, document, template, interactive
textobjectSi type=text{ "body": "mensaje" }
imageobjectSi type=image{ "link": "url" } o { "id": "media_id" }
videoobjectSi type=video{ "link": "url" } o { "id": "media_id" }
audioobjectSi type=audio{ "link": "url" } o { "id": "media_id" }
documentobjectSi type=document{ "link": "url", "filename": "archivo.pdf" }
templateobjectSi type=template{ "name": "...", "language": { "code": "es_AR" }, "components": [...] }

Enviar texto

curl -X POST https://api.waspytech.com/api/v2/messages \
  -H "Authorization: Bearer wspy_..." \
  -H "Content-Type: application/json" \
  -d '{
    "phoneNumberId": "550e8400-e29b-41d4-a716-446655440000",
    "to": "+5491126032641",
    "type": "text",
    "text": { "body": "Hola! Tu pedido fue despachado." }
  }'
Los mensajes de texto libre requieren una ventana de servicio activa (24hs desde el último mensaje del contacto). Si la ventana expiró, usá un template. Ver Ventana de servicio.

Enviar template

curl -X POST https://api.waspytech.com/api/v2/messages \
  -H "Authorization: Bearer wspy_..." \
  -H "Content-Type: application/json" \
  -d '{
    "phoneNumberId": "550e8400-e29b-41d4-a716-446655440000",
    "to": "+5491126032641",
    "type": "template",
    "template": {
      "name": "hello_world",
      "language": { "code": "en_US" }
    }
  }'

Enviar template con variables

curl -X POST https://api.waspytech.com/api/v2/messages \
  -H "Authorization: Bearer wspy_..." \
  -H "Content-Type: application/json" \
  -d '{
    "phoneNumberId": "550e8400-e29b-41d4-a716-446655440000",
    "to": "+5491126032641",
    "type": "template",
    "template": {
      "name": "confirmacion_pedido",
      "language": { "code": "es_AR" },
      "components": [
        {
          "type": "body",
          "parameters": [
            { "type": "text", "text": "María" },
            { "type": "text", "text": "#1847" }
          ]
        }
      ]
    }
  }'

Enviar imagen

curl -X POST https://api.waspytech.com/api/v2/messages \
  -H "Authorization: Bearer wspy_..." \
  -H "Content-Type: application/json" \
  -d '{
    "phoneNumberId": "550e8400-e29b-41d4-a716-446655440000",
    "to": "+5491126032641",
    "type": "image",
    "image": { "link": "https://ejemplo.com/producto.jpg", "caption": "Producto nuevo" }
  }'

Response 201

{
  "data": {
    "id": "msg-uuid",
    "conversationId": "conv-uuid",
    "direction": "outbound",
    "type": "text",
    "status": "queued",
    "createdAt": "2026-04-13T15:00:00.000Z"
  },
  "meta": { "requestId": "..." }
}

Idempotencia

Incluí el header Idempotency-Key para evitar envíos duplicados (máx 256 caracteres, expira en 24hs). Ver Idempotencia.
curl -X POST https://api.waspytech.com/api/v2/messages \
  -H "Authorization: Bearer wspy_..." \
  -H "Idempotency-Key: pedido-1847-confirmacion" \
  -H "Content-Type: application/json" \
  -d '{ ... }'
Si la request se repite con la misma key dentro de 24hs, recibís la respuesta original cacheada con header Idempotency-Replayed: true.

Errores frecuentes

CódigoStatusDescripción
SERVICE_WINDOW_EXPIRED403La ventana de 24hs expiró, usá un template
INVALID_CHANNEL400El phoneNumberId no existe o no pertenece a tu cuenta
CHANNEL_NOT_CONNECTED403El canal no está conectado
INVALID_MESSAGE_TYPE400Tipo de mensaje no válido
INVALID_PHONE400Número de teléfono con formato inválido
IDEMPOTENCY_CONFLICT409Otra request con la misma key está en proceso

Comportamiento

  • Si el contacto no existe, se crea automáticamente con el número.
  • Si no hay conversación previa, se crea una nueva.
  • El mensaje se encola y se envía de forma asíncrona. El status inicial es queued.
  • Consultá el estado final con GET /messages/{id}.

GET /messages/

Consultar un mensaje por ID. Útil para verificar el estado de envío. Scope requerido: messages:read
curl https://api.waspytech.com/api/v2/messages/MSG_ID \
  -H "Authorization: Bearer wspy_..."

Response 200

{
  "data": {
    "id": "msg-uuid",
    "conversationId": "conv-uuid",
    "direction": "outbound",
    "type": "text",
    "content": { "text": { "body": "Hola! Tu pedido fue despachado." } },
    "status": "delivered",
    "waMessageId": "wamid.HBgLNT...",
    "errorCode": null,
    "errorMessage": null,
    "createdAt": "2026-04-13T15:00:00.000Z"
  },
  "meta": { "requestId": "..." }
}

Estados posibles

queuedsentdeliveredread (o failed) Para más detalle, ver Estados de mensajes.