Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Decrypt Webhook Body

To decrypt the webhook body, use the helper function below:

const crypto = require('crypto');
async function decrypt(hash, key, iv) {

    try {

        const content = hash;
        const decipher = await crypto.createDecipheriv(algorithm, key.substring(0, 32), Buffer.from(iv, 'hex'));
        const decrypted = Buffer.concat([decipher.update(Buffer.from(content, 'hex')), decipher.final()]);
        try {
            return JSON.parse(decrypted.toString());
        } catch (e) {
            return decrypted.toString()
        }
    } catch (err) {

        return false;
    }
}


// Usage
const decrypted = await decrypt(
  webhookBody.hash,
  yourApiKey,
  webhookHeaders['x-api-key'],
);

Required Parameters

  1. hash - This is returned from the webhook endpoint

  2. key - Your Live API key is available on your dashboard

  3. iv - This is passed in the webhook header as x-api-key

  4. algorithm - The algorithm used is aes-256-ctr

Last updated