Skip to main content
Every webhook request from KyrenPay includes a cryptographic signature that you should verify to ensure the request is authentic and hasn’t been tampered with.

Signature Algorithm

KyrenPay uses HMAC-SHA256 to sign webhook payloads:
The signature and timestamp are sent in HTTP headers:

Verification Steps

1

Extract headers

Read X-Kyren-Signature and X-Kyren-Timestamp from the request headers.
2

Check timestamp

Verify the timestamp is within 5 minutes (300000 milliseconds) of the current time. This prevents replay attacks.
3

Compute expected signature

Concatenate timestamp + "." + raw_request_body, then compute HMAC-SHA256 using your webhook secret.
4

Compare signatures

Compare the computed signature with the one in the header. Use constant-time comparison to prevent timing attacks.

Code Examples

Register the raw Webhook route before any global JSON parser, or parse JSON only on regular routes. Verify headers and the original body before parsing the event. The examples below require your durable inbox adapter: uniquely save an event ID and pending payload before returning 2xx; a worker must retry and fulfill idempotently. Invalid headers return a rejection, not an unhandled exception. Each retry uses a fresh sending timestamp; use the header, not created_at, for signature verification.

Node.js

Python

Go

Important security considerations:
  • Always verify signatures before processing events
  • Use constant-time comparison functions to prevent timing attacks
  • Reject requests with timestamps older than 5 minutes (300000 ms) to prevent replay attacks
  • Use the raw request body for signature verification (before JSON parsing)