Receive outgoing webhooks

In this guide

Keyseal sends a signed HTTPS request to your server when a sale, licence, subscription or release changes. Use these notifications to fulfil purchases and update your own records. To show feedback in a buyer's browser, use the embedded checkout events. Buy buttons and hosted pages

Connect a receiver

Open Settings → Webhooks in the publisher console. Create an endpoint, select its events, and store the signing secret in your server configuration. The console reveals the secret on creation and rotation. The worker uses a sealed copy to sign deliveries. Rotation takes effect for subsequent sends, including queued deliveries, so update the receiver promptly.

An endpoint belongs to one organization and one environment. Its URL must use HTTPS, contain no credentials and fit within 2,048 characters. It may have a description of up to 500 characters. Choose individual event types or ["*"] to include all current and future types. You can create up to 10 endpoints per organization and environment. Management requires an admin role or an API key with the admin scope.

All routes below are relative to /api/v1/webhooks. Creation and rotation return the new secret once and reject Idempotency-Key. Use the endpoint's test action to queue a signed ping to that endpoint.

Action HTTP CLI under keyseal webhooks
Discover types GET /event-types event-types
List or create endpoints GET or POST /endpoints list, create --url https://example.com/keyseal --event order.created
Read, edit or remove an endpoint GET, PATCH or DELETE /endpoints/{endpoint_id} show, update, delete
Rotate a signing secret POST /endpoints/{endpoint_id}/rotate-secret rotate-secret
Queue a test delivery POST /endpoints/{endpoint_id}/test test
List deliveries or inspect one GET /deliveries or GET /deliveries/{delivery_id} deliveries list --status failed, deliveries show
Replay a delivery POST /deliveries/{delivery_id}/retry deliveries retry

Endpoint IDs start with whe_ and delivery IDs with whd_. In the CLI, create subscribes to all types when you omit --event. Supply an ID to commands acting on an existing endpoint or delivery. The API, CLI and MCP each return the signing secret during creation and rotation.

MCP exposes webhooks_event_types_list, webhooks_endpoints_list, webhooks_endpoints_create, webhooks_endpoints_get, webhooks_endpoints_update, webhooks_endpoints_delete, webhooks_endpoints_rotate_secret, webhooks_endpoints_test, webhooks_deliveries_list, webhooks_deliveries_get and webhooks_deliveries_retry.

Events and payloads

Type Trigger
order.created A new order, including its grant, has been recorded. Its discount field (id, code_id, name, amount, never the code’s text) is that of the purchase that used a discount code made in Keyseal, null otherwise. For a subscription the event may go out without discount if the invoice arrives before the session; GET /orders/{id} shows it afterwards
licence.created A purchase, first subscription payment, free claim or manual issue created a licence
licence.renewed A purchased renewal extended a licence's update entitlement
licence.revoked, licence.suspended, licence.reinstated A licence changed to the corresponding state
activation.created, activation.released A machine was activated, reactivated or released
subscription.created, subscription.renewed The first or a later subscription invoice was paid
subscription.updated, subscription.canceled Subscription details changed or the subscription ended
subscription.payment_failed Payment failed on a subscription that already issued a licence. A failed first payment before issue is ignored
release.published A product release was published
ping An administrator requested a test. It is delivered independently of the endpoint's selected types

Events and their business changes are written in the same transaction. A rollback cancels both. Free and manually issued licences have no associated order. Lemon Squeezy imports emit no events. In particular, a migrated subscription does not emit subscription.created. Revoking a licence announces the revocation with an empty list of active machines.

The POST body is UTF-8 JSON. Its fields are id (an event ID starting with evt_), type, created (an ISO 8601 UTC timestamp), environment (test or live) and data. All deliveries of the same event share its ID. Deduplicate by this ID, including retries and manual replays. Events can arrive out of order.

Event family Contents of data
Licence Management API licence detail. Its origin is stripe, free, manual or imported. Only the last four characters of the licence key are present
Order Management API order detail, including grants
Activation {"licence": …, "activation": …} using the licence detail and machine representations
Subscription The subscription object from order detail
Release Management API release detail, including files
Ping {"endpoint_id": "whe_…"}

A new subscription licence is issued before its subscription is linked, so its licence.created payload has subscription: null. Use subscription.created for the link. An earlier subscription.updated may carry a null licence_id.

Replaying a delivery preserves the original event data. If an older licence event has no origin field, read it from GET /api/v1/licences/{licence_id}.

Verify a delivery

Keyseal sends Content-Type: application/json, User-Agent: Keyseal-Webhooks/1, Keyseal-Event-Id, Keyseal-Event-Type and Keyseal-Signature: t=<unix-seconds>,v1=<hex>.

Read the raw bytes before parsing JSON. Reject timestamps more than five minutes from your server clock. Compute HMAC-SHA256 over the ASCII timestamp, a single period and the exact body bytes, using the endpoint secret as the key. Compare signatures in constant time. Each retry is signed with a fresh timestamp.

Python with FastAPI

import hashlib
import hmac
import time


def verify_signature(secret, body, header, *, tolerance=300, now=None):
    parts = dict(item.split("=", 1) for item in header.split(",") if "=" in item)
    try:
        timestamp = int(parts["t"])
        received = parts["v1"]
    except (KeyError, ValueError):
        return False
    current = time.time() if now is None else now
    if not current - tolerance <= timestamp <= current + tolerance:
        return False
    signed = f"{timestamp}.".encode() + body
    expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected.encode(), received.encode())
import os
from fastapi import FastAPI, HTTPException, Request

app = FastAPI()
secret = os.environ["KEYSEAL_WEBHOOK_SECRET"]


@app.post("/keyseal")
async def receive(request: Request):
    body = await request.body()
    if not verify_signature(secret, body, request.headers.get("Keyseal-Signature", "")):
        raise HTTPException(status_code=400)
    event = await request.json()
    # Record event["id"] and enqueue your work durably before acknowledging.
    return {"received": True}

Node with Express

const crypto = require("node:crypto");
const express = require("express");
const app = express();
const secret = process.env.KEYSEAL_WEBHOOK_SECRET;
if (!secret) throw new Error("Configure the webhook signing secret");

function verifySignature(secret, rawBody, header) {
  const parts = Object.fromEntries(header.split(",").map(item => item.split("=")));
  const t = Number(parts.t);
  if (!Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > 300) return false;
  if (typeof parts.v1 !== "string" || !/^[0-9a-f]{64}$/.test(parts.v1)) return false;
  const expected = crypto.createHmac("sha256", secret)
    .update(String(t) + ".").update(rawBody).digest();
  return crypto.timingSafeEqual(expected, Buffer.from(parts.v1, "hex"));
}

app.post("/keyseal", express.raw({ type: "application/json" }), (req, res) => {
  if (!verifySignature(secret, req.body, req.get("Keyseal-Signature") || "")) {
    return res.sendStatus(400);
  }
  const event = JSON.parse(req.body.toString("utf8"));
  // Record event.id and enqueue your work durably before acknowledging.
  res.sendStatus(200);
});

Delivery, retry and replay

Keyseal queues a separate delivery for each subscribed active endpoint. Its worker sends deliveries concurrently and allows ten seconds for DNS, connection and response. A 2xx response acknowledges delivery. Redirects are treated as failures. After a failed attempt, the retry delays are 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours, 12 hours, 24 hours and 24 hours. After the ninth unsuccessful attempt the delivery is marked failed.

Each worker claims up to 20 deliveries per pass in due-time order, with at most four per endpoint. Across all its endpoints and both environments, a publisher can use two of the process’s eight DNS slots. A lookup holds its slot until the resolver returns, even if the delivery has timed out. After one second waiting for a slot, the attempt fails with dns_error and follows the retry schedule. Two workers can therefore claim up to eight distinct deliveries for one endpoint across their two passes and run up to four simultaneous DNS lookups for its publisher.

During the free beta the journal retains events and deliveries for 30 days. In a commercial environment the current plan sets the retention period and may lower the endpoint allowance. When the monthly attempt allowance is exhausted, queued deliveries and retries stay pending. The worker keeps their events, spends no attempt, and checks again within an hour or at midnight UTC on the first day of the next month, whichever comes first. Already claimed attempts run to completion. After the delivery settles, retention is counted from the creation of the event. Filter by endpoint, event type (including ping) or status. A delivery is pending, sending, succeeded or failed. Its detail includes the sent payload, attempts, last HTTP status and up to 1,024 bytes of the receiver's last response. Keep responses short and free of credentials.

Last error Meaning
http_<status> The receiver returned a non-2xx status
timeout, dns_error, connect_error, tls_error A deadline, name resolution, connection or TLS check failed
blocked_address DNS returned an address that fails the public-address check
request_error, send_error The worker encountered another transport or send error
invalid_url, vault_error The URL or sealed secret is unusable. These failures stop automatic retries
lease_expired The worker stopped during an attempt. Work resumes when its lease expires if attempts remain
endpoint_deleted, endpoint_disabled, event_not_selected The endpoint was removed, turned off or unsubscribed. The worker skips the send without spending an attempt
event_missing The associated event is missing

Correct the cause of a failure, then replay from the journal. Replay keeps the event ID, clears the previous error and queues up to nine fresh attempts. It can also redeliver a succeeded event. A deleted endpoint returns 404 webhook_endpoint_not_found. An in-progress delivery returns 409 webhook_delivery_in_progress.

Receiver addresses

Use a public HTTPS endpoint. At setup, Keyseal rejects credentials in the URL, local names, single-label names and non-public IP literals. At send time, every resolved address must be public. The worker handles embedded IPv4 addresses according to their IPv4 destination and rejects private, link-local, shared and reserved ranges. It connects directly to a checked address and verifies TLS against the original hostname. A public HTTPS tunnel is suitable for receiving test deliveries during local development.

All guides