Webhook Integration

Validate every callback with HMAC SHA-256, reject stale timestamps, and design idempotent consumers.

Headers

HeaderDescription
X-Webhook-SignatureHMAC SHA-256 digest (hex)
X-Webhook-TimestampUnix timestamp used in signature base string
X-Request-IdUnique request correlation identifier

Signature Verification Example (PHP)

$payload = file_get_contents('php://input');
$timestamp = $_SERVER['HTTP_X_WEBHOOK_TIMESTAMP'] ?? '';
$provided = $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'] ?? '';
$expected = hash_hmac('sha256', $timestamp.'.'.$payload, $secret);

if (! hash_equals($expected, $provided)) {
    http_response_code(401);
    exit('invalid signature');
}

Delivery Rules

  1. Respond with HTTP 2xx quickly after signature and timestamp validation.
  2. Process the event asynchronously in your application worker.
  3. Store event IDs to protect against duplicate callback retries.