Webhooks

In addition to the APIs that Leap offers, you can also subscribe to portfolio webhook events to be proactively informed about changes to your Leap portfolio. This guide aims to quickly get you up and running.

❗️

Dispatch Webhook Events

Webhook events for dispatch notifications have been supported for years and are currently setup independently of this general webhook service. See the Dispatch Webhook Events guide for setting up and receiving dispatch webhooks.

Step 1: Expose an endpoint on your server

Webhooks are HTTP callbacks sent to an endpoint on your server.

To receive webhook events, you need a server that has the following:

  • An endpoint that can receive a JSON payload.
  • An open TCP port for HTTPS traffic (must be 443, 8443, or 8843) with TLSv1.2 or TLSv1.3.
📘

Tip: use webhook.site for testing

If you're not ready to expose an endpoint on your server yet, you can go to https://webhook.site to create a webhook subscription URL, and use that temporarily in order to see the Leap push notifications.

Step 2: Set your webhook URL & subscribe to events

There are two ways in which you can configure webhooks:

When creating a new webhook, you'll always need to select one or more webhook event types to subscribe to. A list of supported event types and their example payloads is in the Webhook Events section of the API reference docs.

Example Request

{
  "headers": [
    {
      "name": "x-api-key",
      "value": "your-test-key"
    }
  ],
  "receiver_url": "https://webhook.site/4a0a9a89-d571-4ab7-ae8c-f5c864a3e5d1",
  "event_types": [
    "meter.created"
  ]
}

When you first create a webhook, the response contains a signing_secret:

Example Response

{
  "webhook_id": "8f14e45f-ceea-467f-a0e6-8b4c1d2f3a10",
  "signing_secret": "whsec_pSz3guN3Bvj-B1CamLeVpIpLiBTA-y0rw6XBgmxBznk"
}

Signing Secret

Leap uses the signing secret to sign every webhook event it sends to your endpoint. The signature is in the x-leap-signature header. To verify incoming requests are from Leap, store the secret securely, for example in a secret manager, because your endpoint needs it to verify that a webhook event comes from Leap. Step 4 below, Verify the Leap Signature, explains how.

The signing_secret is only returned:

  • When you create a webhook. Each webhook has its own secret.
  • When you update a webhook with rotate_secret=true, for example PUT /webhooks/{webhook_id}?rotate_secret=true. This generates a new secret, which replaces the old one immediately. The request body must still include the full webhook configuration.

You can also create webhooks, get the signing secret, and rotate it in the Partner Portal.

Updating a webhook without rotate_secret=true keeps the current secret and does not return it. Leap cannot show a secret again; if you lose it, rotate it. Webhooks created before signing was introduced have no secret and are sent without the header until you rotate.

Webhook Security

Verifying the x-leap-signature header is the recommended way to authenticate webhook events from Leap (see step 4). You can also include an API key or authentication token in the headers array, for example to reject requests early at your API gateway.

Note: all header names, including x-leap-signature, are sent in lowercase, regardless of how they were configured in the headers array.

📘

Same Signature Scheme as Dispatch Webhooks

These portfolio webhook events use the same signature scheme as dispatch webhook notifications, so you can reuse your verification code for both. Each webhook still has its own signing secret.

Step 3: Test your webhook subscription

You don't have to wait for an actual event to be triggered by Leap. You can use the Test Webhook endpoint to conveniently test your webhook subscription. Test webhook events are signed in the same way as real webhook events, so use them to test your implementation of step 4.

Retries on Timeouts & Errors

Leap will attempt a series of retries for any notifications that timeout or result in response errors. Check out the webhook retry mechanism guide for more details.

Step 4: Optionally, Verify the Leap Signature

Leap signs every webhook event with a Stripe-style, timestamped HMAC-SHA256 signature. Use it to check that the webhook event comes from Leap, the body was not changed in transit, and it is not an old webhook event being replayed. The timestamp is part of the signature, so it cannot be changed.

How Leap signs a webhook event

  1. Leap serializes the webhook event to bytes once and sends exactly those bytes as the request body. The signature is calculated over those same bytes.
  2. timestamp = the current time in Unix seconds.
  3. signed_payload = {timestamp}.{body}
  4. v1 = hex(HMAC-SHA256(signing_secret, signed_payload)). The key is the full signing secret, including the whsec_ prefix, as UTF-8 bytes. Do not base64-decode it.
  5. Leap adds the header:
x-leap-signature: t=1759658400,v1=93fd212342b16ef77bd0f5630a1ca5fa02972fedef7bbf8962cd54634853a08f

How to verify a webhook event

  1. Read the raw request body before parsing the JSON. If you parse the JSON and serialize it again, whitespace or field order may change and the signature won't match.
  2. Split the x-leap-signature header on , and each part on the first =. Take t and the v1 value(s), and ignore unknown keys. A future signature scheme may add, for example, a v2.
  3. Compute HMAC-SHA256 of {t}.{raw body} with your signing secret.
  4. Compare the result with v1 using a constant-time comparison.
  5. Reject the webhook event if t is more than 5 minutes from your current time. Keep your server clock in sync using NTP.

If verification fails, respond with 401 and don't process the webhook event.

Every retry is signed again with a new t, so retried webhook events pass the timestamp check. Webhook events sent with the Test Webhook endpoint in step 3 are signed in the same way, so use them to test your implementation.

Rotating the secret. A rotated secret is used immediately. Webhook events sent before your endpoint uses the new secret fail verification. You can accept both the old and the new secret for a short time. Alternatively, rely on the retries: once you use the new secret, retried webhook events pass verification as long as they're still within the 8-hour retry window.

Test vector. Use these values to check your implementation:

Secretwhsec_pSz3guN3Bvj-B1CamLeVpIpLiBTA-y0rw6XBgmxBznk
Timestamp1759658400
Body{"event":"test"}
Expected headert=1759658400,v1=93fd212342b16ef77bd0f5630a1ca5fa02972fedef7bbf8962cd54634853a08f

Did this page help you?