Failed to process webhook: Error: Could not validate request HMAC

Shopify Partner
13 1 2

Hi everybody, when I tried to migrate to new Node template, the webhooks always throws this error: “Error: Could not validate request HMAC”.

Does anyone know how to fix this? I tried searching on Google but nothing works. This is my code snippet:
	express.text({ type: "*/*" }), // Even with this, it still throws the error No body was received when processing webhook
	function (req: any, res: any, next: any): any { // This one fix the error above
		req.body = JSON.stringify(req.body);
	shopify.processWebhooks({ webhookHandlers: GDPRWebhookHandlers as any })
Replies 4 (4)

Shopify Staff
2731 302 783

Hi Nam7911,


There's a couple things you could do here to troubleshoot this HMAC validation error:


Verify the webhook path: First off you should double-check that the shopify.config.webhooks.path value matches the webhook path you set in your Shopify Partner Dashboard or Admin. The webhook path should be the same in both places.


Verify the body parsing middleware: In your code snippet, you're using express.text({ type: "*/*" }) as the middleware to parse the request body. This might cause issues with the HMAC validation. Instead, you can use express.json() middleware to parse the request body as JSON.


You could also verify the webhook secret and ensure that you have correctly set the webhook secret in your Shopify Partner Dashboard or Admin.


Hope these options help - if not let us know here and we'll dig into this a bit more.


Liam | Developer Advocate @ 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 or the Shopify Web Design and Development Blog

Shopify Partner
13 1 2

Thanks for replying Liam,

I have double-checked the webhook path, they are identical, which is why I think they ran in the first place, which gave me the error.


For the "express.text({ type: "*/*" })" middleware, I followed the docs here

Basically how I understand is the new webhook will only take the rawBody, which is a string. Hence the use of the middleware (Although it doesn't work).


Can you point out to me where to find the set up for the webhook secret in Partner Dashboard? I tried looking everywhere and couldn't find anything.

Shopify Partner
1 0 0

Any update here? I'm getting the same issue.

Shopify Partner
4 0 3

I had fixed this by following this step -


  1. npm run dev -- --reset, create a new app 
  2. Go to your partner's dashboard and click on all apps
  3. Click on your app
  4. Click on app setup
  5. Scroll to the bottom to find "Protected customer data access" 
  6. Check all the options from up to down don't miss anything, and save.
  7. Install the app
  8. Create an order to see whether the webhooks are working or not.

I followed these steps and it's worked for me.