waiaconnect

Documentación / Esencial

Enviar un mensaje de texto

POST /v1/messages

POST /v1/messages con type: "text". Devuelve 202 (aceptado, NO enviado): se encola y se drena a ritmo controlado. El header Idempotency-Key (UUID) es obligatorio — reintentar con la misma key devuelve el mismo registro (200) en vez de duplicar. Identificá el número emisor con connectionId (conn_…) o from (phoneNumberId).

curl -X POST https://api.waiaconnect.com/v1/messages \
  -H "Authorization: Bearer wc_live_YOUR_API_KEY" \
  -H "Idempotency-Key: REPLACE-WITH-A-UNIQUE-ID" \
  -H "Content-Type: application/json" \
  -d '{"connectionId":"conn_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX","to":"5493511234567","type":"text","text":{"body":"Hello from WAIA Connect 👋"}}'
const res = await fetch("https://api.waiaconnect.com/v1/messages", {
  method: "POST",
  headers: {
    "Authorization": "Bearer wc_live_YOUR_API_KEY",
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
  "connectionId": "conn_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "to": "5493511234567",
  "type": "text",
  "text": {
    "body": "Hello from WAIA Connect 👋"
  }
})
});
console.log(await res.json()); // { id: "msg_…", status: "queued" }
<?php
$ch = curl_init("https://api.waiaconnect.com/v1/messages");
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer wc_live_YOUR_API_KEY",
    "Idempotency-Key: " . bin2hex(random_bytes(16)),
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => json_encode(["connectionId" => "conn_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX","to" => "5493511234567","type" => "text","text" => ["body" => "Hello from WAIA Connect 👋"]]),
]);
echo curl_exec($ch);
import requests, uuid
res = requests.post("https://api.waiaconnect.com/v1/messages",
  headers={
    "Authorization": "Bearer wc_live_YOUR_API_KEY",
    "Idempotency-Key": str(uuid.uuid4()),
  },
  json={"connectionId":"conn_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX","to":"5493511234567","type":"text","text":{"body":"Hello from WAIA Connect 👋"}})
print(res.json())  # {"id": "msg_…", "status": "queued"}

to va en formato E.164 (solo dígitos, 8–15). En el ejemplo va tu propio número para que puedas probar contra vos mismo.

Respuesta: { id: "msg…", status: "queued" } (o held con un reason). El estado se sigue con GET /v1/messages/:id._