Application webhooks (TenancyEngine)
Receive real-time event notifications when tenant lifecycle events occur in your application — tenants created, deleted, entitlements changed, feature flags toggled, and more.
Console: Application workspace → Webhooks (/applications/:id/webhooks)
Requires Applications configure to create, update, or delete endpoints. Read-only access shows existing endpoints.
How it works
When an event occurs (e.g. tenant.created), TenancyEngine queues a signed HTTP POST to every active endpoint configured for that application. Deliveries are retried with exponential back-off (10 s → 1 min → 5 min → 30 min → 2 h → 24 h) for up to 6 attempts. After 6 failures the delivery is dead-lettered.
Adding an endpoint
- Click Add endpoint.
- Enter the HTTPS URL that will receive events.
- Optionally narrow the subscription — enter a comma-separated list of event types (e.g.
tenant.created,tenant.deleted) or leave as*to receive all events. - Click Create endpoint — your signing secret is displayed once. Copy it before dismissing.
Verify with a standard webhooks library
Every delivery also carries the three headers defined by the open Standard Webhooks specification, so a library you already use can verify it:
webhook-id— a unique id for the delivery, the same on every retry of it. Use it to ignore a duplicate.webhook-timestamp— unix seconds.webhook-signature—v1,{base64}. For 24 hours after a secret rotation it holds two entries separated by a space, one for the new secret and one for the old, so a receiver holding either secret passes.
The libraries want the secret as whsec_ followed by the base64 of your secret. Build it from the secret shown in the Console:
printf 'whsec_%s' "$(printf '%s' "$ENDPOINT_SECRET" | base64 -w0)"// Node: npm i standardwebhooks
import { Webhook } from "standardwebhooks";
const wh = new Webhook("whsec_" + Buffer.from(process.env.ENDPOINT_SECRET).toString("base64"));
const event = wh.verify(rawBody, { "webhook-id": id, "webhook-timestamp": ts, "webhook-signature": sig });# Python: pip install standardwebhooks
import base64, os
from standardwebhooks.webhooks import Webhook
wh = Webhook("whsec_" + base64.b64encode(os.environ["ENDPOINT_SECRET"].encode()).decode())
event = wh.verify(raw_body, {"webhook-id": id, "webhook-timestamp": ts, "webhook-signature": sig})// .NET: no extra package needed
var ok = WebhookSignatureVerifier.VerifyStandard(rawBody, id, timestamp, signature, endpointSecret);Pass the raw request body, exactly as received. The X-TE-Signature header described next keeps working unchanged.
Verifying signatures
Every delivery includes two headers:
X-TE-Event— the event type (e.g.tenant.created)X-TE-Signature—t={unixTimestamp},v1={hexHmac}(Stripe-style). For 24 hours after a secret rotation it also carriesv1_previous={hexHmac}, the same payload signed with the previous secret (see Rotating a secret).
The signature is HMAC-SHA256(secret, "{timestamp}.{rawBody}") — note the timestamp is prefixed onto the payload before hashing, and verification must use the raw request body string exactly as received (re-serializing a parsed object will not match). Compare using a constant-time comparison to avoid timing attacks.
Also check the timestamp's age, not just the HMAC. A signature with a correct HMAC but a stale t= is a replayed request — someone captured a valid delivery earlier (from a proxy log, a compromised intermediary, etc.) and is resending it now. Reject any signature whose timestamp is more than 5 minutes old (or in the future); every SDK helper below does this for you by default.
The easiest way to verify correctly is the WebhookSignatureVerifier helper in TenancyEngine.Sdk (.NET, packages/TenancyEngine.Sdk), verifyWebhookSignature() in @tenancyengine/sdk (TypeScript, packages/tenancyengine-sdk), or VerifyWebhookSignature() in the Go module (packages/tenancyengine-go) — all three reject a signature whose timestamp is more than 5 minutes old (or in the future) by default, and all three accept an optional wider/narrower window if your receiver has a specific reason to need one:
using TenancyEngine.Sdk;
var isValid = WebhookSignatureVerifier.Verify(rawBody, request.Headers["X-TE-Signature"], secret);
// Optional 4th argument overrides the default 5-minute replay window:
// WebhookSignatureVerifier.Verify(rawBody, header, secret, TimeSpan.FromMinutes(10));If you're hand-rolling verification instead, the equivalent — including the replay-window check — is:
var parts = signatureHeader.Split(',').Select(p => p.Split('=', 2)).ToDictionary(p => p[0], p => p[1]);
var timestamp = long.Parse(parts["t"]);
var receivedSig = parts["v1"];
// During a rotation overlap there is also parts["v1_previous"]; accept a match on either
// (see "Rotating a secret" below). The SDK helpers above already do this.
// Reject stale or future-dated signatures BEFORE comparing the HMAC — this is what stops a
// captured valid signature from being replayed indefinitely.
var age = DateTimeOffset.UtcNow - DateTimeOffset.FromUnixTimeSeconds(timestamp);
if (age < TimeSpan.Zero || age > TimeSpan.FromMinutes(5))
return false;
var expectedSig = Convert.ToHexString(
HMACSHA256.HashData(Encoding.UTF8.GetBytes(secret), Encoding.UTF8.GetBytes($"{timestamp}.{rawBody}"))
).ToLowerInvariant();
var valid = CryptographicOperations.FixedTimeEquals(
Convert.FromHexString(expectedSig),
Convert.FromHexString(receivedSig));Rotating a secret
Click Rotate secret on an endpoint to generate a new signing key. The new secret is shown once, so copy it before you dismiss the dialog.
Rotation does not break a receiver that still has the old secret. For 24 hours after a rotation, every delivery is signed with both secrets: v1 uses the new secret and v1_previous uses the previous one. A receiver that checks either value keeps working while you deploy the new secret. After 24 hours v1_previous is no longer sent and only the new secret verifies.
- The SDK helpers (
WebhookSignatureVerifier.VerifyinTenancyEngine.Sdk2.3.0 and later,verifyWebhookSignaturein@tenancyengine/sdk0.4.0 and later, andVerifyWebhookSignaturein the Go module) accept either value. Earlier SDK versions check onlyv1, so update your receiver's secret before the overlap ends. - Rotating again during the overlap replaces the previous secret with the one that was current. Only one previous secret is kept.
- If the old secret leaked, rotate with no overlap. With an org API key, call
POST /api/v1/runtime/applications/{applicationId}/webhooks/{webhookId}/rotate-secretwith the body{ "graceHours": 0 }(allowed range: 0 to 720; the default is 24). The response includespreviousSecretPrefixandpreviousSecretExpiresAtUtcwhile an overlap is running.
Delivery log
Click Deliveries on an endpoint to see the last 50 delivery attempts — event type, HTTP status code, attempt count, and next retry time.
Spotting a failing address
You do not have to open each address to find out. The console Overview flags any app whose webhook address is failing and offers Resend failed for the last 24 hours. See Console overview.
Disabling an endpoint
Edit an endpoint and uncheck Active to pause deliveries without deleting the endpoint. Reactivate at any time.
Automations: start from a recipe
Below the webhook list, Automations run a short sequence for one customer when something happens in your application: wait, ask a person to approve, then ask your application to do the work.
Choose Add definition version, then pick a recipe under Start from a recipe to fill in the form. Nothing is saved until you review it and choose Publish version.
- Follow up a day after sign-up: waits one day, then asks your application to send a follow-up.
- Ask a manager before a refund: holds a refund request for a day for someone to approve or reject, then runs it.
- Win-back offer after a trial ends: waits three days, asks a manager to approve for up to two days, then sends the offer.
- Reminder a week after an invoice is sent: waits seven days, then asks your application to send a reminder, retrying temporary failures up to ten times.
The event and command names in a recipe are examples. Replace them with the names your own application sends and handles.
Wait before running (minutes) adds a pause at the start. Leave it at 0 to start straight away; the longest wait is 365 days (525,600 minutes). A published version cannot be edited, so to change a recipe's timing publish the next version.
Related
- Application features — feature flags that trigger events
- Application tenants — tenant lifecycle
- Tenant entitlements: freshness, ordering and notifications — what
entitlement.changedcarries and how to use it - Outbox dead-letter — view failed deliveries that exhausted retries