Handle webhook events received out of order

Use event occurrence fields and file version numbers to reject stale webhook work, then reconcile current state when no ordering field exists.

Last reviewed

Webhook arrival order is not a state-order guarantee. Retry delays and manual redelivery can make an older payload arrive after a newer event, and delivery-row creation time records the attempt rather than the original business change.

Four panels show comparing event occurrence data, rejecting an older file version, reconciling an unversioned deletion, and committing the newest accepted state.
Four panels show comparing event occurrence data, rejecting an older file version, reconciling an unversioned deletion, and committing the newest accepted state. Open full-size screenshot.

Steps

  1. Verify the signature, deduplicate by the top-level event id, and parse type, created, workspace_id, and data. Event IDs are opaque values and must not be sorted.
  2. Store top-level created as the event’s Unix-second occurrence time, not a total-order sequence. Separate events may share the same second, and a redelivery retains the old payload while receiving a new delivery row.
  3. For file.uploaded, key state by data.file_id and compare the integer data.version. Apply a higher version, treat the same event ID as duplicate, and ignore a lower version that arrives after a newer one.
  4. For share.accessed, use data.accessed_at for the access occurrence and retain every distinct event ID. Two views of one link are separate events even when their timestamps are close.
  5. For file.deleted, note that current payloads provide file_id, name, and permanent but no resource version. Reconcile current Dosya state through an independently authorized API read before triggering an irreversible downstream deletion.
  6. Test by delaying an older upload event, processing a higher file version first, and then releasing the old request. Confirm the stored version does not move backward and both attempts receive deliberate acknowledgements.

The sender offers no ordering contract across events or endpoints. Keep per-resource monotonic state where a reliable field exists and use current-state reconciliation where it does not.

Reference for “Handle webhook events received out of order”: Dosya REST API overview page with Get API Key and View SDKs links.
Reference for “Handle webhook events received out of order”: Dosya REST API overview page with Get API Key and View SDKs links. Open full-size screenshot.

Expected result

The consumer converges on the newest known file version, retains distinct share accesses, and refuses to infer deletion order from random IDs or delivery timestamps. Late retries cannot roll downstream state backward.

Two events have the same created value. Use the resource-specific field or reconcile current state; the envelope timestamp has one-second precision.

A delete cannot be reconciled. Quarantine that event for operator review and return according to the receiver’s retry policy instead of guessing at an irreversible transition.

Was this helpful?

Loading helpfulness results…

Voting saves a necessary ballot cookie for up to 180 days so you can change your answer.

Questions and replies

Ask about the steps in this guide. Questions are reviewed before publication.

Keep account details, credentials and private files out of public questions. Use private support for those.

Loading questions…

    Sign in to your Dosya account to ask a question.

    Check the outcome before you retry

    Use these shared checks when a task needs a second look.