Ignore duplicate webhooks
Shopify's webhook system minimizes sending duplicate webhooks to subscribers such as apps. However, subscribers might receive the same webhook more than once.
Your app should process webhooks using idempotent operations, so that receiving the same webhook a second time doesn't result in a different outcome.
However, if your webhook processing isn't idempotent, then you can detect duplicate webhook events by leveraging headers. The following are Shopify's guidelines:
Get the event ID from the headers. This is the
X-Shopify-Event-Id
header and the same value across more than one webhook indicates a duplicate. Visit about webhooks for more information about events and webhook headers.Use this ID within an asynchronous function to check if the webhook had already been received (you'll need persistent storage to compare with previously delivered webhooks and to store new IDs).
If the webhook has already been received, then avoid duplicate processing by simply skipping it.
- Learn about troubleshooting your webhooks.