> ## Documentation Index
> Fetch the complete documentation index at: https://docs.routa.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# Retries and replay

> How Routa retries failed deliveries, when an endpoint is disabled and how to replay exhausted deliveries.

A server that is down for six hours should not make you lose events or open a support ticket. Routa retries, keeps what was not delivered and lets you replay it.

## Retry policy

A delivery gets up to **8 attempts** over about 20 hours, with growing delays and a random variation of ±20%.

| Attempt | Delay after the previous one |
| - | - |
| 1 | Immediate |
| 2 | 10 seconds |
| 3 | 30 seconds |
| 4 | 2 minutes |
| 5 | 10 minutes |
| 6 | 1 hour |
| 7 | 6 hours |
| 8 | 12 hours |

### What counts as success

* A `2xx` response within **10 seconds**.
* Anything else is a failure: another status, a timeout or a connection error. Routa does not follow redirects.
* The response body is ignored. Routa reads at most the first 4 KB.

### `410 Gone`

A `410` response is treated as permanent removal: the delivery is abandoned right away, without using up its attempts. Use `410` only if you really do not want that event anymore. Other `4xx` responses (such as a temporary `401` from your authentication layer) are retried as usual.

## Delivery states

Each combination of event and endpoint is a **delivery** (`whd_...`) with its own state.

| State | Meaning |
| - | - |
| `pending` | Created, not attempted yet. |
| `in_flight` | Being attempted now. |
| `retrying` | Failed and waiting for the next attempt. |
| `succeeded` | Delivered with a `2xx`. |
| `exhausted` | Ran out of attempts, or received a `410`. This is the *dead-letter* state. |

List the deliveries of an endpoint, filtering by state:

```bash theme={null}
curl "https://api.routa.chat/v1/webhook_endpoints/whe_01J8.../deliveries?state=exhausted" \
  -H "Authorization: Bearer $ROUTA_API_KEY"
```

Each item shows `attempt_count`, `next_attempt_at`, `last_response_status` and `last_error_code`, which helps you understand why a delivery fails. Deliveries can be queried for **30 days**.

## Replay exhausted deliveries

After you fix your endpoint, replay what was left behind.

> [tab] One delivery
>
> ```bash theme={null}
> curl -X POST \
>   https://api.routa.chat/v1/webhook_endpoints/whe_01J8.../deliveries/whd_01J8.../replay \
>   -H "Authorization: Bearer $ROUTA_API_KEY"
> ```
>
> Only `exhausted` deliveries can be replayed. Any other state returns `409 webhook_delivery_not_replayable`.

> [tab] All of an endpoint
>
> ```bash theme={null}
> curl -X POST \
>   https://api.routa.chat/v1/webhook_endpoints/whe_01J8.../deliveries/replay \
>   -H "Authorization: Bearer $ROUTA_API_KEY"
> ```
>
> The response reports how many deliveries were replayed:
>
> ```json theme={null}
> { "replayed_count": 12 }
> ```

## Automatic disabling

To keep the system from spending capacity on a dead endpoint, Routa **disables** an endpoint (`status: "disabled_by_system"`) in either of these cases:

* 100 consecutive failures; or
* 24 hours without a single success, with at least 20 delivery attempts.

Pending deliveries stop, and the new status shows up on the endpoint and in the dashboard. **Events are still recorded in the log**, so nothing is lost.

To re-enable it, call `POST /v1/webhook_endpoints/{id}/enable`. Re-enabling **replays every exhausted delivery in a batch** and responds with `replayed_count`, the number replayed.

```bash cURL theme={null}
curl -X POST https://api.routa.chat/v1/webhook_endpoints/whe_01J8.../enable \
  -H "Authorization: Bearer $ROUTA_API_KEY"
```

```ts Node.js theme={null}
await routa.webhooks.enable(webhookId)
```

You can also pause an endpoint yourself with `POST /v1/webhook_endpoints/{id}/disable` (`status: "disabled_by_user"`), during maintenance for example.

## Endpoint status

| Status | Meaning |
| - | - |
| `enabled` | Receiving deliveries. |
| `disabled_by_user` | Disabled by you. |
| `disabled_by_system` | Disabled automatically after continuous failures. |

The endpoint object carries `consecutive_failures`, `last_success_at` and `last_failure_at` so you can monitor its health.

## Isolation

Webhook deliveries run on their own queue and workers. A slow endpoint of yours never delays message sending, yours or another customer's. Each endpoint receives at most **8 deliveries at the same time**. If its responses stay consistently above 5 seconds, Routa lowers this limit to **1 delivery at a time**, until the endpoint answers fast again. Respond `2xx` early and do the work afterwards.

The webhook endpoint of a partner organization, which receives the events of all its customers, has a higher limit: 32 concurrent deliveries. See [Organization webhook](https://docs.routa.chat/en/partners/webhook.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.