How can I capture raw Shopify webhook payloads & headers to debug a delivery surge?

We’re seeing a large spike in Shopify webhook deliveries. How should I capture the raw request (headers + body) and correlate each delivery with Shopify’s delivery metadata so we can identify retries, duplicate deliveries, or the originating app/store? We run our webhook handlers in Gadget.dev — any concise guidance, code snippets, or recommended tools for logging raw bodies, verifying HMAC, and matching X-Shopify-Webhook-Id/X-Shopify-Topic/X-Shopify-Shop-Domain to Shopify delivery logs would be very helpful.
6 Replies
Chocci_Milk
Chocci_Milk2mo ago
Hello, You should be able to see the trigger topic and payload using the trigger object on action context. There's also the same information on the the logs in the Gadget log viewer. I believe that you can see the headers from the request object on context as well. There's actually a thread from today where we discussed how to add monitoring to your application if that's something that interests you: https://discord.com/channels/836317518595096598/1435972704770723912 Here are some docs for the context objects: https://docs.gadget.dev/reference/gadget-server#action-contexts There might be more information also available on the connections.shopify context object
Amiya_2607
Amiya_2607OP2mo ago
Thanks, Antoine! That helps a lot. Just to confirm — if we want to log the full raw payload (and possibly headers) for incoming Shopify webhooks so we can analyze spikes or duplicates later, would accessing context.trigger and context.request be sufficient? Also, is there a recommended way to persist or export those logs (for example, pushing them to an external log store or dashboard) so we can visualize webhook volume trends over time?
Chocci_Milk
Chocci_Milk2mo ago
I think that it should be sufficient but I haven't tried it myself. There's no way to export or persist the logs. We have a log retention period of 30 days. You would need to use something like sentry or another monitoring tool (or build it out yourself) to have more analytics Btw, we don't modify the payload that Shopify sends us when putting it in the trigger payload of an action Its not the raw request but it is the exact data that they send us
Amiya_2607
Amiya_2607OP2mo ago
Thanks a lot, Antoine! That clears it up — really appreciate the help
Chocci_Milk
Chocci_Milk2mo ago
No problem! Glad I could help
Gizmo
Gizmo4d ago
Do you like this answer? ​

Did you find this page helpful?