> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/technical-reference/triggers-and-webhooks/duplicate-events-and-delivery-failures.md).

# Duplicate Events and Delivery Failures

Event senders can deliver an event more than once, especially after a timeout. Design event-driven workflows to recognize repeated deliveries.

![Reconcile a repeated event before writing again](https://1957915746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSQ1Sgy933krTyK0S4JpP%2Fuploads%2FKNnxbJFZlEnZoOwhf1FX%2Fduplicate-events-and-delivery-failures.png?alt=media)

Illustrative application logic. Use a durable, atomic event ledger and provider-supported idempotency where available. Recovery must reconcile interrupted operations; a missing completion marker does not prove the external write failed.

<details>

<summary>Copy the example</summary>

```python
event_id = event.stable_id
state = durable_ledger.lookup(event_id)

if state == "completed":
    return previous_result(event_id)
if state in {"processing", "uncertain"}:
    return reconcile_destination(event_id)

# Use an atomic claim to avoid concurrent duplicate work.
if durable_ledger.claim_if_absent(event_id):
    perform_and_record_business_operation(event)
```

</details>

## Before you begin

A stable event ID or business identifier from the sender.

## Key concepts

| Term           | Definition                                                                                                                                                                    |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Event ID       | An identifier for a delivered event. Use it to recognize duplicates where the sender guarantees stable event identifiers.                                                     |
| Idempotency    | A contract under which repeating the same intended operation does not create an additional change. Use it only where the provider or public operation explicitly supports it. |
| Retry          | A repeated attempt after a failed or uncertain operation. It can repeat external changes; use it only when the result is understood.                                          |
| Side effect    | A change outside the returned answer, such as creating a record or sending email. Cancellation or release rollback does not undo a completed side effect.                     |
| Reconciliation | Checking the run or destination to determine whether an uncertain operation completed. Do this before retrying a write after a timeout.                                       |

## Handle duplicate events

1. Keep the event identifier with the workflow input.
2. Check whether the corresponding business operation has already completed before writing again.
3. Inspect delivery history and run history together when an event is missing or repeated.

Repeated delivery does not unintentionally repeat the business operation.

## Behavior and limitations

Do not assume exactly-once delivery. A sender can retry even when the first workflow is still running. A failed delivery response does not establish that no external change occurred. Use provider-supported idempotency controls where available and preserve external record IDs for reconciliation.

## Related resources

[Trigger Activation and Execution Context](https://docs.stackai.com/technical-reference/triggers-and-webhooks/trigger-activation-and-execution-context.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/technical-reference/triggers-and-webhooks/duplicate-events-and-delivery-failures.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
