waiaconnect

Documentazione / Completo

Consegne di un webhook: vederle e rinviarne una abbandonata

GET /v1/webhooks/{id}/deliveries

Markdown

Programmi con l'IA? Collegala al tuo account via MCP: controlla la tua configurazione, crea webhook e modelli con la tua conferma e scrive il codice. Scopri come →

GET /v1/webhooks/{id}/deliveries restituisce le ultime consegne di quel webhook, la più recente per prima: eventType, status (pending, delivered, failed mentre si ritenta, abandoned dopo l'ultimo tentativo), attempts, lastStatusCode, un lastError breve, abandoned e se si può rinviare (redeliverable, fino a redeliverableUntil). Filtri per status, since e limit (da 1 a 100). Mai il payload.

Rinviare. POST /v1/webhooks/{id}/deliveries/{deliveryId}/redeliver rimanda una consegna abbandonata: una consegna nuova (redeliveryId, un altro whd_…) con lo stesso evt_…, così la tua deduplicazione continua a funzionare. Risponde 202. Ogni abbandonata si rinvia una volta, entro 72 h dall'evento, con il webhook attivo; fino a 60 all'ora per account.

# the abandoned deliveries of one webhook (never the payload)
curl "https://api.waiaconnect.com/v1/webhooks/wh_…/deliveries?status=abandoned" -H "Authorization: Bearer wc_live_YOUR_API_KEY"
# redeliver one (same evt_, new whd_; within 72 h; webhook active)
curl -X POST "https://api.waiaconnect.com/v1/webhooks/wh_…/deliveries/whd_…/redeliver" -H "Authorization: Bearer wc_live_YOUR_API_KEY"
# → 202 { "id": "whd_…", "redeliveryId": "whd_…", "eventId": "evt_…", "status": "pending" }
const H = { "Authorization": "Bearer wc_live_YOUR_API_KEY" };
const wh = "wh_…";
const r = await (await fetch(`https://api.waiaconnect.com/v1/webhooks/${wh}/deliveries?status=abandoned`, { headers: H })).json();
for (const d of r.deliveries.filter(d => d.redeliverable)) {
  await fetch(`https://api.waiaconnect.com/v1/webhooks/${wh}/deliveries/${d.id}/redeliver`, { method: "POST", headers: H });
}
<?php
$h = ["Authorization: Bearer wc_live_YOUR_API_KEY"];
$ch = curl_init("https://api.waiaconnect.com/v1/webhooks/wh_…/deliveries?status=abandoned");
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $h]);
foreach (json_decode(curl_exec($ch), true)["deliveries"] as $d) {
  if (!$d["redeliverable"]) continue;
  $p = curl_init("https://api.waiaconnect.com/v1/webhooks/wh_…/deliveries/" . $d["id"] . "/redeliver");
  curl_setopt_array($p, [CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $h]);
  curl_exec($p);
}
import requests
H = {"Authorization": "Bearer wc_live_YOUR_API_KEY"}
wh = "wh_…"
r = requests.get(f"https://api.waiaconnect.com/v1/webhooks/{wh}/deliveries", params={"status": "abandoned"}, headers=H).json()
for d in r["deliveries"]:
    if d["redeliverable"]:
        requests.post(f"https://api.waiaconnect.com/v1/webhooks/{wh}/deliveries/{d['id']}/redeliver", headers=H)

409 WEBHOOK_DELIVERY_NOT_ABANDONED: la consegna è ancora in fase di nuovi tentativi.

409 WEBHOOK_INACTIVE: riattiva il webhook (active: true) prima di rinviare.

410 WEBHOOK_DELIVERY_EXPIRED: sono passate le 72 h o è già stata rinviata.