Getting Shopify webhook body in response by webhook ID

shubu
Shopify Partner
1 0 0

My Shopify app handles webhooks by logging the domain name and webhook id after verifying hmac, this keeps it short and responds with 200 to Shopify within a second, I'm trying to then access the response body of these webhooks by calling the Webhook API here(https://shopify.dev/api/admin-rest/2022-01/resources/webhook#get-webhooks-webhook-id), while passing appropriate params to the endpoint(eg:https://myshopifydomain/admin/api/2022-01/webhooks/webhook-id-here.json) API key and the access token are passed in the call, still, for all webhooks, I get a 404 error. What am I doing wrong?

 

data to test:

webhook-id: 23890ff1-d50a-4939-ad1e-0c95732353c5


or anyone who has implemented a system through which they fetch past webhook response data using any other method? please help @Shopify.

Reply 1 (1)

jon551
Shopify Staff
28 7 5

Hi Shubu,

 

Thanks for your post. The REST Webhooks API works with the numerical webhook subscription ID's returned by a GET call to /admin/api/2022-01/webhooks.json, which refer to the information about a subscription such as the address, topic, and fields [Reference Doc]. This is different from the topic specific data that gets sent each time those webhook subscriptions fire in the store.

 

There isn't currently a way to get a single historical instance of the topic specific body data from a webhook that has been sent in the past, so a couple best practices are to:

 

  • Register webhooks through apps created in the Partner dash instead of store based custom apps to enable monitoring of the delivery status of the webhooks through the webhooks dashboard [Webhook Delivery Metrics - Shopify Dev Docs]
  • Implement occasional reconciliation jobs which intentionally poll for related store data (eg.  products or orders instead of individual webhooks) in case some webhooks weren't received [Webhook Best Practices - Shopify Dev Docs]

Hope you have a great day,

Jon551 | API Support @ 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