# Replay a time range

`POST /webhooks/{id}/replay`

Requires the `businesses` scope.

Queues a new delivery for every event in `[from, to)` this endpoint would have received (its own event and business filters apply; `events` / `businessId` narrow further). Reads the event log, so it also covers events the endpoint never had a delivery for (created later, or paused at the time). An event that already has a delivered or pending delivery to this endpoint is skipped unless `includeDelivered`. For an outage on your side: "we were down from 02:00 to 05:00". Bounded per call (1,000 events); a longer window answers `truncated: true` with `nextFrom` to continue from. Refused while the endpoint is paused or auto-disabled.

## Path parameters

| Name | Type | | Description |
|---|---|---|---|
| `id` | string | **required** | Webhook endpoint id. |

## Body

| Field | Type | | Description |
|---|---|---|---|
| `from` | string | **required** | Start of the window (ISO timestamp, inclusive). |
| `to` | string |  | End of the window (ISO timestamp, exclusive). Default: now. |
| `events` | array of string |  | Only these event types (within what the endpoint subscribes to). |
| `businessId` | string |  | Only one business under your key. |
| `includeDelivered` | boolean |  | Also queue events that already reached this endpoint. Default false. |

## Response

`201`: `{ "ok": true, … }`

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean | **required** |  |
| `queued` | integer | **required** | Deliveries created by this call. |
| `skipped` | integer | **required** | Events in the window that already had a delivered or pending delivery to this endpoint. |
| `truncated` | boolean | **required** | More events matched than one call queues. |
| `nextFrom` | string |  | When truncated: pass as `from` to continue. |
| `from` | string |  |  |
| `to` | string |  |  |

Errors: `400`, `401`, `403`, `404`, `429`. Every failure answers `{ "error", "reason", "hint", "param", "doc_url", "retryable", "request_id" }`: branch on `reason`, and read `hint` for what to change (https://docs.billos.co.il/errors.md).

## Examples

### cURL

```bash
curl -X POST "$BASE/webhooks/$DOC_ID/replay" \
  -H "X-Api-Key: $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "2026-07-01"
  }'
```
### Node

```node
const res = await fetch(`${BASE}/webhooks/${DOC_ID}/replay`, {
  method: 'POST',
  headers: {
    'X-Api-Key': KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "from": "2026-07-01"
  }),
})
const data = await res.json()
if (!data.ok) throw new Error(data.reason)
```
### Python

```python
import requests
res = requests.post(
    f"{BASE}/webhooks/{DOC_ID}/replay",
    headers={"X-Api-Key": KEY},
    json={
      "from": "2026-07-01"
    },
)
data = res.json()
```