Skip to content
شعار البي شعار البي El-BDevelopers

Webhooks

Signature verification

Each delivery is signed with the endpoint's secret, so your server can tell El-B's requests from anyone else's.

The signature

X-ElB-Signature holds sha256= followed by the hexadecimal HMAC-SHA256 of the raw request body, keyed with the signing secret you received when you registered the endpoint or rotated its secret.

Sign the bytes you received, before any JSON parsing: re-encoding the body changes it (spacing, escaped characters) and the signature no longer matches.

Verifying it

$body = file_get_contents('php://input');
$expected = 'sha256='.hash_hmac('sha256', $body, getenv('ELB_WEBHOOK_SECRET'));

if (! hash_equals($expected, $_SERVER['HTTP_X_ELB_SIGNATURE'] ?? '')) {
    http_response_code(401);
    exit;
}

$event = json_decode($body, true);
// Answer at once; do the work in the background.
http_response_code(200);

Compare in constant time (hash_equals, timingSafeEqual, compare_digest), never with ==.

Rotating the secret

Rotate the signing secret returns a new secret that signs every delivery from that moment, retries included. Deploy it to your receiver right away.