Duplicate webhook Id

Solved
wealthman
New Member
6 0 0

I see lots of questions re duplicate webhooks, but I can't find anything definitive that I should be looking at in determining whether the webhook is a duplicate for the same event. I had thought for the same event that triggered the webhook - say customers/create, for example - any duplicates would have the same X-Shopify-Webhook-Id. That doesn't seem to be the case though. Am I missing something? Is there any easy/definitive way of checking whether I have already received a webhook triggered by a specific and single event like creating customer "Joe Soap".

Accepted Solution (1)

Accepted Solutions
james-langille
Shopify Staff (Retired)
Shopify Staff (Retired)
70 15 24

This is an accepted solution.

Hello, @wealthman, I'm a little confused why the X-Shopify-Webhook-Id does not seem to be the answer for you, since the primary reason why we added it was for apps to handle duplicate webhooks when necessary.

tl;dr: If you see a duplicate X-Shopify-Webhook-Id, then you should be able to safely ignore the duplicate, since it's literally the same instance of a webhook being sent more than once. This happens sometimes as a result of our architecture which prioritizes ensuring webhooks are not dropped over avoiding duplicates.

Create and delete hooks are pretty straightforward, since each resource can (usually) be only created and maybe deleted once. However, for more context into this problem: consider that a customer is updated multiple times. Say that your app receives 3 updates to a customer that changes their name to "Joe Soap" (A) -> "Joe Snap" (B) -> "Joe Soap" (A'). Problem here is that it can't really be known (without an id) if the third update was actually a different update (A and A' were two different updates from the user), or a duplicate that we sent as a result of our architecture to ensure no webhooks are dropped (A = A'). With the X-Shopify-Webhook-Id, apps should be able to tell if the third update and the first were the same event (where B should be the final state, since it came second to A), or if they were two different events and should both be considered (where A' should be the final state, since it came last).

Hopefully this makes sense, and let me know if I can help clarify this for you more.

james-langille | Developer @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Reply 1 (1)
james-langille
Shopify Staff (Retired)
Shopify Staff (Retired)
70 15 24

This is an accepted solution.

Hello, @wealthman, I'm a little confused why the X-Shopify-Webhook-Id does not seem to be the answer for you, since the primary reason why we added it was for apps to handle duplicate webhooks when necessary.

tl;dr: If you see a duplicate X-Shopify-Webhook-Id, then you should be able to safely ignore the duplicate, since it's literally the same instance of a webhook being sent more than once. This happens sometimes as a result of our architecture which prioritizes ensuring webhooks are not dropped over avoiding duplicates.

Create and delete hooks are pretty straightforward, since each resource can (usually) be only created and maybe deleted once. However, for more context into this problem: consider that a customer is updated multiple times. Say that your app receives 3 updates to a customer that changes their name to "Joe Soap" (A) -> "Joe Snap" (B) -> "Joe Soap" (A'). Problem here is that it can't really be known (without an id) if the third update was actually a different update (A and A' were two different updates from the user), or a duplicate that we sent as a result of our architecture to ensure no webhooks are dropped (A = A'). With the X-Shopify-Webhook-Id, apps should be able to tell if the third update and the first were the same event (where B should be the final state, since it came second to A), or if they were two different events and should both be considered (where A' should be the final state, since it came last).

Hopefully this makes sense, and let me know if I can help clarify this for you more.

james-langille | Developer @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog