---
updatedAt: 2025-05-28T00:18:23.000Z
agentTools:
  projectIndex: https://coinify.readme.io/llms.txt
---

# Validate webhook signature

```javascript JavaScript
const crypto = require('crypto');

const sharedSecret = 'shared-secret';

const body = req.body;
const signature = req.headers['X-Coinify-Webhook-Signature'];

const hash = crypto.createHmac('sha256', sharedSecret)
  .update(JSON.stringify(body))
  .digest('hex');

return hash === signature;

```

```json Response Example
{"success":true}
```

# Import an encryption library

<!-- javascript@1 -->

This library will be used to encrypt the body with the shared secret.

# Assign your secret key in a variable

<!-- javascript@3 -->

This value is known only to you and Coinify.

# Read the request body

<!-- javascript@5 -->

This property contains the data sent to your endpoint.

# Read the signature header

<!-- javascript@6 -->

The value of this header is what you need to validate.

# Encrypt the request body with the secret

<!-- javascript@8-10 -->

Generate a hash to validate that what you have received in the body was encrypted with the shared secret.

# Validate the received signature

<!-- javascript@12 -->

When the received signature header and the calculated hash do not match, then the request body should not be accepted.