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

# Failure & Retry Policy

This page explains what happens when a webhook cannot be delivered: what counts as a failure, when the request is sent again, and how repeated failures change the status of a webhook subscription.

The policy has two goals: do not lose events when your endpoint has a short outage, and do not keep sending requests to an endpoint that is broken.

## What counts as a failed delivery

A webhook is delivered as an HTTP `POST` request with a JSON body. A delivery **fails** in any of these cases:

* Your endpoint answers with a status code outside the `2xx` and `3xx` ranges.
* The connection is not opened within **5 seconds**, or the full response does not arrive within **10 seconds** (a timeout).
* The connection fails for another reason, for example a DNS or TLS error.
* The request is redirected more than **2 times**. Redirects are followed with the same `POST` method and body.

> [!WARNING]
>
> **A late response is a failure.** A valid `2xx` response that arrives after the timeout is not accepted, and the event is sent again.

What happens next depends on the `autoRetry` option of the subscription. It is turned on by default.

| Failure | `autoRetry: true` | `autoRetry: false` |
| :- | :- | :- |
| Timeout | Sent again by the full retry schedule. | Sent again up to 4 times. The 5th timeout in a row disables the webhook. |
| Any other failure | Sent again by the full retry schedule. | Not sent again. The webhook is disabled at once. |

## Retry schedule

With the auto retry, a failed event is sent again up to **8 times**. The delay grows after each failure:

| Attempt | Delay after the previous attempt |
| :- | :- |
| 1st retry | 2 minutes |
| 2nd retry | 6 minutes |
| 3rd retry | 30 minutes |
| 4th retry | 1 hour |
| 5th retry | 5 hours |
| 6th retry | 18 hours |
| 7th retry | 1 day |
| 8th retry | 2 days |

All 8 retries together take about **4 days**. For this reason we do not recommend the auto retry for time-sensitive webhooks, for example a reminder that is useful only before some event starts.

Without the auto retry, a timeout uses the first four delays of the same table: 2 minutes, 6 minutes, 30 minutes and 1 hour.

### The schedule belongs to the webhook

Failures are counted **per webhook subscription**, not per event:

* Your endpoint gets one attempt per delay, no matter how many events are waiting.
* While a webhook waits for its next attempt, all its events wait together, new events included. They are sent in the order they were created.
* One successful delivery resets the failure counter. The other waiting events are then sent without a delay.

### Request headers

Each request carries these headers:

```http theme={null}
X-Opigno-LIP-Delivery: <delivery-id>
X-Opigno-LIP-Retry: <retry counter>
X-Opigno-LIP-Signature: <signature-value>
```

| Header | Description |
| :- | :- |
| `X-Opigno-LIP-Delivery` | The unique ID of the delivery. It is the same for all attempts of one event. |
| `X-Opigno-LIP-Retry` | How many times this event was already sent and failed. `0` marks the first attempt. |
| `X-Opigno-LIP-Signature` | The signature of the subscription. The header is sent only when the subscription has a signature. |

## Webhook statuses after failures

Repeated failures change the status of the subscription. The users who can manage webhooks get an email when a webhook becomes degraded or paused, and when it is disabled automatically.

| Status | When it is set | What happens to events |
| :- | :- | :- |
| `ACTIVE` | The webhook is enabled and the deliveries work. | Sent as usual. |
| `DEGRADED` | 6 attempts in a row have failed (the first attempt and 5 retries). Only with the auto retry. | Still sent by the retry schedule. A successful delivery sets `ACTIVE` again. |
| `PAUSED` | All 8 retries have failed. Only with the auto retry. | New events are kept and not sent until the delivery is resumed. |
| `DISABLED` | The webhook was disabled by a user, or automatically by one of the rules below. | New events are not recorded. The events that were waiting are marked as failed. |

A webhook is disabled automatically when:

* It stays `PAUSED` for **14 days** without a resume.
* The auto retry is turned off and a delivery fails for any reason other than a timeout.
* The auto retry is turned off and **5 timeouts** happen in a row.

### Resuming a paused webhook

A paused webhook is resumed from its edit page in the platform, with the **Save & resume delivery** button. See [Webhooks](https://docs.opigno.com/webhooks.md#webhook-statuses).

* The kept events are sent in the order they were created, to the current target URL of the webhook. You can correct the URL before you resume.
* The failure counter is kept. If the first delivery after the resume fails, the webhook is paused again at once. A successful delivery gives the full retry schedule back.

### Enabling a disabled webhook

When a webhook is disabled, its waiting events are marked as failed and are never sent. After you enable it again, only new events are sent. The events that happened while it was disabled are not sent either.

## Best practices

1. **Answer fast, process later.** Return a `2xx` response as soon as you have stored the request, and do the real work in the background. A response after 10 seconds counts as a failure.
2. **Make your endpoint idempotent.** The same event can arrive more than once, for example when your `2xx` response was late. Store the value of `X-Opigno-LIP-Delivery` and skip a delivery that you have already processed.
3. **Watch the retry header.** A value of `X-Opigno-LIP-Retry` above `0` means that earlier attempts failed. Use it for monitoring and alerts.
4. **Turn the auto retry off for time-sensitive webhooks.** A retried event can arrive up to 4 days late.
5. **React to the emails.** A `DEGRADED` or `PAUSED` webhook needs a fix on your side before the 14 days end.

## Summary

* A delivery fails on a status code outside `2xx`/`3xx`, on a timeout (5 seconds to connect, 10 seconds to answer), on a connection error or on more than 2 redirects.
* With the auto retry: up to 8 retries in about 4 days, then the webhook is paused and keeps new events for up to 14 days.
* Without the auto retry: only timeouts are sent again, and any other failure disables the webhook at once.
* Use `X-Opigno-LIP-Delivery` to remove duplicates and `X-Opigno-LIP-Retry` to track the attempts.


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