# Webhook deliveries: see them and redeliver an abandoned one

`GET /v1/webhooks/{id}/deliveries`

`GET /v1/webhooks/{id}/deliveries` returns that webhook's latest deliveries, newest first: `eventType`, `status` (`pending`, `delivered`, `failed` while it is retried, `abandoned` after the last attempt), `attempts`, `lastStatusCode`, a short `lastError`, `abandoned` and whether it can be redelivered (`redeliverable`, until `redeliverableUntil`). Filter by `status`, `since` and `limit` (1 to 100). Never the payload.

**Redeliver.** `POST /v1/webhooks/{id}/deliveries/{deliveryId}/redeliver` sends an **abandoned** delivery again: a new delivery (`redeliveryId`, another `whd_…`) with the **same** `evt_…`, so your deduplication keeps working. It answers `202`. Each abandoned delivery is redelivered once, within 72 h of the event, with the webhook active; up to 60 per hour per account.

## Examples

### cURL

```bash
# 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" }
```

### Node.js

```javascript
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

```php
<?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);
}
```

### Python

```python
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)
```

## Notes

- `409 WEBHOOK_DELIVERY_NOT_ABANDONED`: the delivery is still being retried.
- `409 WEBHOOK_INACTIVE`: reactivate the webhook (`active: true`) before redelivering.
- `410 WEBHOOK_DELIVERY_EXPIRED`: the 72 h passed or it was already redelivered.
