# Delivery and retries

How Valeron retries a failed delivery, what order to expect, and when an endpoint is switched off.

## Success

A delivery succeeds when your server answers with a `2xx` status within 10 seconds. Any other status, a timeout or a connection error is a failure.

## Retries

Each delivery gets up to 8 attempts over about 24 hours: one right away, then 1 minute, 5 minutes, 30 minutes, 2 hours, 5 hours, 10 hours and 24 hours after the event. Redirects are not followed, and an address that resolves to a private network is refused.

A test `ping` is sent once and never retried. A manual retry is sent at once; if it fails, the delivery carries on with its schedule while attempts remain.

## Delivery log

Valeron keeps every attempt for 30 days. List them with `GET /v1/webhook-endpoints/{endpoint_id}/deliveries`, and send one again with `POST /v1/webhook-deliveries/{delivery_id}/retry`.

```bash title="cURL"
curl "https://api.valeron.io/v1/webhook-endpoints/whe_01JEX5A2K4/deliveries?limit=20" \
  -H "Authorization: Bearer $VALERON_API_KEY"
```

## Ordering and repeats

Order is **not guaranteed**, and the same event can arrive more than once. Build your receiver for that:

- Store the event `id` and ignore an event you have already handled.
- Compare the object's `updated_at` with what you hold, and ignore a state that is older than yours.
- When in doubt, fetch the object from the API: it is the source of truth.

## When an endpoint is switched off

If every delivery to an endpoint has failed for 3 days, Valeron switches it off. The endpoint shows `is_enabled: false` and a `disabled_reason`, and the Owner is notified. Deliveries due to it wait, and go out once you fix your receiver and turn it back on. Retrying a delivery while the endpoint is off is `409 endpoint_disabled`.

```bash title="cURL"
curl -X PATCH "https://api.valeron.io/v1/webhook-endpoints/whe_01JEX5A2K4" \
  -H "Authorization: Bearer $VALERON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"is_enabled": true}'
```

After a gap, run an `updated_since` sync to catch what you missed. See [Pagination and syncing](/docs/pagination-and-syncing/).
