On this page
Why older guidance can fail
Some tutorials use the event ID as the only unique key. That can suppress legitimate work when multiple subscriptions receive notifications from one action. Conversely, a delivery ID alone does not prevent two independent subscriptions from creating the same external business record.
Implement two layers of protection
- Authenticate the request using the raw body and Shopify HMAC before trusting headers.
- Persist a delivery key scoped to the app and shop. Use a unique database constraint rather than a read-then-insert check.
- Store the event ID separately for tracing related deliveries.
- Commit the inbox record and durable job together before acknowledging success. A worker should retry unfinished jobs independently of HTTP delivery retries.
- Protect external side effects using a business key, such as shop and order ID for creation of an ERP order. Use an upsert or a destination-supported idempotency key.
Example
Two subscriptions receive a product edit: one updates search and one updates an ERP. They can share an event ID while having distinct delivery IDs. Both jobs must run. A retry of the search delivery must not create a second search job. If two jobs target the same ERP order, the ERP business key provides the second line of protection.
- Replay a signed test delivery twice and confirm one inbox job.
- Send two distinct delivery IDs sharing an event ID and confirm both intended handlers run.
- Simulate a database failure before acknowledgment; verify retry does not lose work.
- Simulate a worker crash after the external write; verify retry does not duplicate the record.
- Reject invalid signatures and test rapid edits to ensure stale data cannot overwrite newer state.

