Receive signed webhooks once in your system.
Runs on your backend. Verify exact bytes before JSON, and commit delivery deduplication with the business effect.
On this page
Create the subscription
Use dashboard Webhooks in your chosen workspace and test environment. Register your owned HTTPS receiver, review and send once, then retain its signing secret when revealed once. Keep the secret private and separate from the workspace credential. Creating or disabling subscriptions requires Manage customers and webhooks. A subscription’s delivery status is observable with Read.
Install Python or PHP. The SDKs include signature verification and a runnable local receiver. Place the signing secret in a 0600 file inside your private 0700 directory, then configure the subscription ID, workspace and environment through non-sensitive configuration.
Run a receiver on your backend
Save the once-only signing secret in a protected file using your local editor, not a command argument. Replace the public IDs below. Inherit AVAILKIT_WORKSPACE_ID and AVAILKIT_ENVIRONMENT=test from your backend setup. Receiver state directories must be owned and mode 0700; the secret must be mode 0600.
mkdir -m 700 private/python-webhooks private/php-webhooks
export AVAILKIT_WEBHOOK_SUBSCRIPTION_ID=YOUR_TEST_SUBSCRIPTION_ID
export AVAILKIT_WEBHOOK_SECRET_FILE="$PWD/private/availkit-webhook.key"
chmod 600 "$AVAILKIT_WEBHOOK_SECRET_FILE"
# Python: standard-library HTTP receiver + SQLite
export AVAILKIT_WEBHOOK_STATE_DIR="$PWD/private/python-webhooks"
python -m availkit.examples.webhook_receiver
# Listens on http://127.0.0.1:8090/webhooks/availkit
# Alternatively PHP: requires the optional pdo_sqlite extension
export AVAILKIT_WEBHOOK_DB_FILE="$PWD/private/php-webhooks/events.sqlite"
php -S 127.0.0.1:8091 vendor/availkit/availkit/examples/webhook-server.php
# Handles http://127.0.0.1:8091/webhook-server.phpRun one receiver at a time in its own terminal. Register an existing owned HTTPS ingress that forwards to the selected loopback path, then create a test booking to generate a real delivery. Confirm one durable handled row for each unique delivery ID; resend the same signed delivery inside its validity window to verify no second effect. The SDK tests also exercise tampering, scope, expiry, duplicate headers and storage-failure retries.
Verify exact bytes and scope
Delivery headers are AvailKit-Delivery-Id and AvailKit-Signature: t=SECONDS,v1=HEX. Decode the secret as base64url into exactly 32 bytes. HMAC-SHA256 covers the timestamp, a literal period and the exact raw body bytes. Reject duplicate signing/delivery headers, an invalid tag, bodies over 16 KiB, and timestamps outside ±300 seconds. Compare tags in constant time before parsing JSON.
The signed body has schemaVersion, deliveryId, subscriptionId, workspaceId, environment and event. Match the signed delivery ID to the header, and verify the subscription/workspace/environment against your receiver configuration. There is no separate event-ID header.
Make the receiver durable
Use a local database transaction: insert the delivery ID under a unique constraint, apply the business effect, and commit both together. A duplicate returns 2xx without repeating the effect. If persistence fails, return 5xx; do not acknowledge before commit.
BEGIN;
INSERT INTO handled_deliveries (delivery_id) VALUES (:verified_delivery_id)
ON CONFLICT DO NOTHING;
-- Only if inserted, apply the narrow business effect in this transaction.
COMMIT;
-- Return 204 after commit; a duplicate also returns 204.The installed Python and PHP receiver examples implement this with SQLite and a synthetic event counter. They are local runnable examples; place them behind your owned TLS ingress for real delivery. Do not expose a development server as a production ingress.
Handle retries deliberately
Delivery is at least once, with up to five attempts. HTTP 408, 425, 429, 5xx or an uncertain transport result can retry after 5 seconds, 30 seconds, 2 minutes and 10 minutes. Most other 4xx are terminal. Disable unwanted subscriptions in the dashboard; an already admitted attempt may have reached the receiver.
Clock sync and durable deduplication are required even when signature validation succeeds. A successful provider/API response does not prove your downstream business effect completed. Inspect delivery IDs and states, without logging secrets or private customer data.