Skip to content
Ideasoft
Webhooks

Webhook Security

Every webhook request carries an HMAC-SHA256 signature of the body — generated with your client_secret — in the X-Ideashop-Hmac-Sha256 header:

Code
base64( hmac_sha256( <raw request body>, <client_secret> ) )

Use the raw body

Compute the signature over the byte-exact raw request body; do not parse the JSON and re-serialize it.

PHP

The minimal verification step (raw body + HMAC):

PHPCode
$data = file_get_contents('php://input'); base64_encode(hash_hmac('sha256', $data, $secret, true));

Full verification example:

PHPCode
<?php $rawBody = file_get_contents('php://input'); $expected = base64_encode(hash_hmac('sha256', $rawBody, $clientSecret, true)); $received = $_SERVER['HTTP_X_IDEASHOP_HMAC_SHA256'] ?? ''; if (!hash_equals($expected, $received)) { http_response_code(401); exit('invalid signature'); }

Node.js

JavascriptCode
const crypto = require("crypto"); const expected = crypto .createHmac("sha256", clientSecret) .update(rawBody) // raw body as a Buffer .digest("base64"); const valid = received.length === expected.length && crypto.timingSafeEqual(Buffer.from(received), Buffer.from(expected));

Use constant-time comparison (hash_equals / timingSafeEqual); do not compare with ===.

Last modified on