HMAC

Modified on Fri, 18 Aug 2023 at 11:30 AM

When Zūm Rails sends data to external services (e.g. when triggering a webhook to a service owned by you), the payload will be authenticated with a hash-based message authentication code (HMAC).

 


The key used to create the HMAC is your Webhook Secret, and you verify it by running the algorithm yourself with the payload and the key to re-create the HMAC.


Your Webhook Secret can be found in the portal under your settings.


 



 


The signature is always sent with the webhook in a header named zumrails-signature


You can verify the authenticity of the webhook response by using HMAC.


 


The HMAC verification process is as follows:


  1. You receive a POST request via the webhook
  2. Your app computes a signature based on payload received, using your Webhook Secret
  3. You verify that your signature matches the zumrails-signature in the request

 

Here are the steps to validate a request coming from Zum Rails

 


1) Retrieve the zumrails-signature header from the webhook:




2) Retrieve the json body of the request. Make sure you are not adding any new spaces or formats. E.g:




3) Using HMAC SHA256 implemented in your programming language, calculate the signature in your side. The body is the payload and the secret is your Webhook Secret.


 

The output should be in Base64 format.


For yours tests, you can use an online HMAC generator. https://www.liavaag.org/English/SHA-Generator/HMAC/ is one example.





 

4) Compare your hash with the value provided under the zumrails-signature in the request, they should match. As you can see, the Result here (hV...gys=) matches the zumrails-signature in the screenshot from step (1) above.


 

A few examples on how to calculate HMAC in different languages: https://github.com/danharper/hmac-examples


Did this answer your question?

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article