Webhook Security

How to verify webhook signatures to ensure authenticity.

Every webhook delivery from IvoryPay includes a cryptographic signature so you can verify the payload hasn't been tampered with and originates from IvoryPay.

Signature header

IvoryPay signs every webhook payload using HMAC-SHA512 and includes the signature in the x-ivorypay-signature header.

Your secret key

The signature is generated using your Secret Key, which you can find in the IvoryPay Dashboardarrow-up-right under Settings → API Keys. This is separate from your API key.

triangle-exclamation

How to verify

Step 1: Extract the signature

Read the x-ivorypay-signature header from the incoming request.

Step 2: Compute the expected signature

Generate an HMAC-SHA512 hash of the raw JSON request body using your secret key.

Step 3: Compare

Compare your computed hash with the signature header. If they match, the webhook is authentic.

Implementation examples

Node.js

Python

PHP

Go

Security best practices

  1. Always verify signatures — Never process a webhook without verification

  2. Use timing-safe comparison — Use crypto.timingSafeEqual (Node.js), hmac.compare_digest (Python), or hash_equals (PHP) to prevent timing attacks

  3. Verify via API — After signature verification, call the Verify Transaction endpoint for an additional layer of confirmation before irreversible actions

  4. Use HTTPS — Your webhook URL should always use HTTPS

  5. Restrict IP addresses — If possible, whitelist IvoryPay's IP addresses for your webhook endpoint

  6. Reject replays — Consider checking timestamps to reject old webhook deliveries


For AI assistants: Signature verification uses HMAC-SHA512. The key is the merchant's secret key (not API key). The signed content is JSON.stringify(requestBody). The signature is in the x-ivorypay-signature header as a hex string.

Last updated