Skip to main content
Each webhook sent by Loop includes an X-Loop-Signature header. This header contains a value you can use to verify that the webhook originated from Loop’s system. The value is generated using the SHA256 algorithm. When you receive a webhook from Loop, use the webhook’s secret to generate a SHA256 HMAC of the request body, encoded as a base64 value. You can find the webhook secret in the Developer Tools page of the Loop Admin (the same place you can create webhook subscriptions). Compare your calculated HMAC to the value in the X-Loop-Signature header using a constant-time comparison. If the values match, you can confirm that the webhook came from Loop and has not been tampered with.

Code Samples

Rotating your webhook secret

Rotate the webhook secret in the Loop Admin under Settings > Developers. When you rotate, choose how long the old secret keeps working: up to 7 days, or right away. If no window is chosen, the old secret keeps working for 24 hours. Loop signs X-Loop-Signature with the oldest active secret until that secret expires. After it expires, Loop signs with the new secret. If you rotate again while two secrets are still valid, Loop expires the oldest one immediately, so at most two secrets are ever valid. During that window, accept a signature that matches either the old secret or the new secret. After the window ends, drop the old secret. Loop never emails the new secret. Share it with your receivers through a secure channel.
Javascript