Skip to main content
Blink securely signs all webhook events it sends to your endpoints. This ensures that the payloads you receive are actually from Blink and have not been tampered with by a third party. You should always verify webhook signatures before processing them in your application.

The Signature Header

When Blink sends a webhook to your server, it includes the following headers:
  • Blink-Signature: The cryptographic signature of the payload (e.g., v1=a1b2c3d4...)
  • Blink-Timestamp: The unix timestamp (in seconds) when the event was dispatched.
  • Blink-Event: The name of the event (e.g., order.paid).

How to Verify the Signature

Blink uses HMAC with SHA-256 to sign webhook payloads. To verify the signature, you need the Signing Secret for your webhook endpoint (which you can find in the Blink dashboard or via the API). Follow these steps to verify the signature:
  1. Extract the timestamp and signature from the headers.
  2. Prepare the signed payload string by concatenating the timestamp, a dot (.), and the raw JSON request body: ${timestamp}.${rawBody}.
  3. Compute the expected HMAC signature using SHA-256, your signing secret, and the signed payload string.
  4. Compare the signatures. If your computed signature matches the one in the Blink-Signature header (stripping the v1= prefix), the webhook is valid!

Example: Node.js (Express)

Here is a complete example of how to verify a webhook signature in a Node.js Express application:

Example: Next.js (App Router)

If you are using Next.js App Router, you can verify webhooks like this:

Replay Attacks

As a best practice to prevent replay attacks, you should check that the Blink-Timestamp is within a reasonable tolerance (e.g., 5 minutes) of your server’s current time.