Webhooks
ulex webhooks: all 34 event types, the exact delivery payload, HMAC-SHA256 signature verification, retry schedule with exponential backoff, the auto-disable threshold, delivery inspection, and idempotency guidance.
Required scopes: read:webhooks, write:webhooks.
#Events
Thirty-four names, a closed set, and append-only — a new event is a version bump, never a rename. Subscribe by name; unknown names are 400 validation_failed at create time, not silently ignored.
#Directory sync
| Event | Fires when |
|---|---|
dsync.activated | a directory becomes active |
dsync.deleted | a directory is deleted |
dsync.user.created | a user appears in a SCIM directory |
dsync.user.updated | a user changes in a SCIM directory |
dsync.user.deleted | a user leaves a SCIM directory |
dsync.group.created | a group appears in a SCIM directory |
dsync.group.updated | a group's membership or attributes change |
dsync.group.deleted | a group is removed from a SCIM directory |
#Users
| Event | Fires when |
|---|---|
user.created | any user is created, by any route |
user.updated | any user field changes |
user.deleted | a user is hard-deleted |
user.suspended | a user is suspended, or deprovisioned over SCIM |
user.unsuspended | a user is unsuspended |
#Organizations
| Event | Fires when |
|---|---|
organization.created | |
organization.updated | |
organization.deleted |
#Connections
| Event | Fires when |
|---|---|
connection.activated | |
connection.deactivated | |
connection.deleted |
#Sessions
| Event | Fires when |
|---|---|
session.created | a user session is created, including cross-app SSO reuse |
session.revoked | a session is revoked — logout, suspend, deprovision, or secret rotation |
#Platform
| Event | Fires when |
|---|---|
domain.verified | |
application.created | |
application.updated | |
api_key.created | |
api_key.revoked | |
deployment.started | |
deployment.succeeded | |
deployment.failed | |
deployment.cancelled | |
mcp.tool_invoked | an MCP tool call ran, per the tenant's sampling policy |
mcp.tool_invoked is sampled by default — every 100th call, plus 100% of ulex_reset_tenant and ulex_revoke_api_key calls. It exists so an agent can see its own footprint, not as a full audit trail; the audit log is the audit trail.
#Create
curl -sS -X POST "$BASE/webhooks" \
-H "Authorization: Bearer $ULEX_API_KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: 3c9d1f77-0b2e-4a58-9d61-5e7a2c40b913" \
-d '{
"url": "https://hooks.example.com/ulex",
"events": ["dsync.user.created", "dsync.user.updated", "dsync.user.deleted", "user.suspended", "session.created"],
"description": "Identity events for the Acme Support pipeline",
"api_version": "2025-01-01"
}'{
"webhook": {
"id": "whk_01M3PSVK981SXWGKG9JXHC1P0Y",
"object": "webhook",
"url": "https://hooks.example.com/ulex",
"status": "enabled",
"events": ["dsync.user.created", "dsync.user.updated", "dsync.user.deleted", "user.suspended", "session.created"],
"secret_prefix": "whsec_3Kq9",
"failure_count": 0,
"disabled_at": null,
"disabled_reason": null,
"last_delivery_at": null,
"last_delivery_status": null,
"api_version": "2025-01-01",
"created_at": "2026-09-29T14:42:17.000Z"
},
"secret": "whsec_3Kq9Xa2mB7yLt4NxZ1pRc6HdE0sJg3AuV8",
"signature_algorithm": "HMAC-SHA256",
"signature_header": "Ulex-Signature",
"signature_example": "t=1790693112,v1=8JmQ1vZ0Xh4n7cW2sT5yP9rB3kD6fG1aH0mNqU4wE7iO2pL5xC8vB1nMg0jKhR3tFyD7wZq2"
}secret is returned once. It is stored encrypted with the tenant KEK and is not retrievable again — not by GET /webhooks/{id}, not by any MCP tool. Persist it in the same call that creates the webhook. To rotate it, create a second endpoint, deploy the new secret, then delete the first.
#URL rules
webhook_url_invalid if the URL is not https:// (loopback http:// is allowed), or contains userinfo. webhook_url_blocked if the host resolves to loopback, link-local, RFC 1918, or a cloud metadata address — the SSRF guard runs at create time and again at every delivery, so a DNS record that changes to 169.254.169.254 after creation is rejected at send time.
#Payload
{
"id": "evt_01M3PSW3WGDDFJFJHZ4QJNNFZD",
"object": "event",
"api_version": "2025-01-01",
"environment": "prod",
"tenant_id": "ten_01M3PSV6K0HFZ62YZ6AKB191WW",
"event": "dsync.user.created",
"event_id": "evt_01M3PSW3WGDDFJFJHZ4QJNNFZD",
"created_at": "2026-09-29T14:42:18.000Z",
"attempt": 1,
"livemode": false,
"request_id": "req_01M3PSW9R0175NAW62NYR403R8",
"data": {
"user": {
"id": "usr_01M3PSWBPGS08FWV4NV7P9VNFN",
"object": "user",
"email": "pat@acme.example",
"email_verified": true,
"first_name": "Pat",
"last_name": "Iyer",
"display_name": "Pat Iyer",
"job_title": "Support Engineer",
"department": "Customer Success",
"status": "active",
"directory_id": "dir_01M3PSVBF8038RK2MW2N263Q2B"
},
"membership": {
"id": "mem_01M3PSW0YRNEQQAP9T1JP9FC2Y",
"organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
"role": "member",
"group_ids": ["grp_01M3PSVED0M9RJTYH5AC72C253"]
},
"organization": { "id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C", "name": "Acme Corp", "slug": "acme" },
"previous_attributes": null
}
}data is event-specific and is a superset of the resource. previous_attributes is present on user.updated and dsync.user.updated, and contains only the keys that changed:
{
"event": "dsync.user.updated",
"attempt": 1,
"data": {
"user": { "id": "usr_01M3PSWBPGS08FWV4NV7P9VNFN", "job_title": "Support Engineer II", "status": "active" },
"previous_attributes": { "job_title": "Support Engineer" }
}
}event_id is the deduplication key and is stable across retries. attempt is 1-based and increments on every retry of the same event.
#Signature verification
Header:
Ulex-Signature: t=1790693112,v1=8JmQ1vZ0Xh4n7cW2sT5yP9rB3kD6fG1aH0mNqU4wE7iO2pL5xC8vB1nMg0jKhR3tFyD7wZq2Signed payload: ` ${timestamp}.${rawBody} — the literal string "<timestamp>."` concatenated with the exact request bytes, HMAC-SHA256, hex encoded.
import { createHmac, timingSafeEqual } from "node:crypto";
export function verifyUlexSignature(
rawBody: Buffer,
header: string | undefined,
secret: string,
toleranceSeconds = 300,
): boolean {
if (!header) return false;
const parts: Record<string, string> = {};
for (const pair of header.split(",")) {
const i = pair.indexOf("=");
if (i > 0) parts[pair.slice(0, i).trim()] = pair.slice(i + 1).trim();
}
const timestamp = parts.t;
const signature = parts.v1;
if (!timestamp || !signature) return false;
// Reject replays of an old, correctly-signed body.
const age = Math.abs(Date.now() / 1000 - Number(timestamp));
if (!Number.isFinite(age) || age > toleranceSeconds) return false;
const expected = createHmac("sha256", secret)
.update(`${timestamp}.`)
.update(rawBody)
.digest("hex");
const a = Buffer.from(expected, "utf8");
const b = Buffer.from(signature, "utf8");
return a.length === b.length && timingSafeEqual(a, b);
}Three rules that are not optional:
- Verify the raw bytes. Re-serialising the parsed JSON changes key order and whitespace and breaks the HMAC. Buffer first, parse second.
- Compare in constant time.
timingSafeEqual, not===. - Check the timestamp before the signature is fine; check it, not just the signature. Without it a captured body replays forever.
Full receiver: Webhook receiver with signature verification.
#Delivery
POST /ulex HTTP/1.1
Host: hooks.example.com
Content-Type: application/json
Ulex-Signature: t=1790693112,v1=8JmQ1vZ0Xh4n7cW2sT5yP9rB3kD6fG1aH0mNqU4wE7iO2pL5xC8vB1nMg0jKhR3tFyD7wZq2
Ulex-Delivery-Id: dlv_01M3PSVM8G1BF1SQ3FQ0FPKJJA
Ulex-Event: dsync.user.created
Ulex-Attempt: 1
X-Ulex-Request-Id: req_01M3PSW9R0175NAW62NYR403R8| Rule | Value |
|---|---|
| Timeout | 5 seconds |
| Success | any 2xx |
| Failure | anything else, or a timeout, or a connection error |
| Max attempts | 8 |
| Backoff | exponential with jitter: 10 s, 30 s, 2 min, 8 min, 30 min, 2 h, 8 h |
| Concurrency | 25 requests/second per endpoint |
| Auto-disable | 8 consecutive failures → status: "disabled", disabled_reason set |
| Re-enable | POST /webhooks/{id}/enable — manual, never automatic |
Answer in under 5 seconds. Queue the work and return 200. A synchronous handler that takes 8 seconds turns one delivery into eight, and after eight the endpoint auto-disables and you silently stop receiving events.
After a successful re-enable, failure_count resets to 0. Events raised while an endpoint is disabled are not replayed when it comes back — they are retained for 30 days as webhook_delivery records with status: "dead_lettered", readable at GET /webhooks/{id}/deliveries?status=dead_lettered.
#Inspect deliveries
curl -sS "$BASE/webhooks/whk_01M3PSVK981SXWGKG9JXHC1P0Y/deliveries?status=failed&limit=20" -H "Authorization: Bearer $ULEX_API_KEY"
curl -sS "$BASE/webhook-deliveries/dlv_01M3PSVM8G1BF1SQ3FQ0FPKJJA" -H "Authorization: Bearer $ULEX_API_KEY"{
"id": "dlv_01M3PSVM8G1BF1SQ3FQ0FPKJJA",
"object": "webhook_delivery",
"webhook_id": "whk_01M3PSVK981SXWGKG9JXHC1P0Y",
"event": "dsync.user.created",
"event_id": "evt_01M3PSW3WGDDFJFJHZ4QJNNFZD",
"status": "delivered",
"attempt": 1,
"max_attempts": 8,
"response_status": 200,
"response_body": "{\"received\":true}",
"error": null,
"duration_ms": 84,
"next_attempt_at": null,
"delivered_at": "2026-09-29T14:42:18.000Z",
"created_at": "2026-09-29T14:42:18.000Z"
}status ∈ pending | in_flight | delivered | failed | dead_lettered. response_body is truncated to 2,000 characters.
Filters: status, event, limit, starting_after, order.
#Test
curl -sS -X POST "$BASE/webhooks/whk_01M3PSVK981SXWGKG9JXHC1P0Y/test" \
-H "Authorization: Bearer $ULEX_API_KEY" -H "Content-Type: application/json" \
-d '{"event":"user.created"}'{
"id": "dlv_01M3PSW2X8E8H2CCW1AX67T8C1",
"object": "webhook_delivery",
"webhook_id": "whk_01M3PSVK981SXWGKG9JXHC1P0Y",
"event": "user.created",
"event_id": "evt_01M3PSW5V0FYTW40CESDH2EDCK",
"status": "in_flight",
"attempt": 1,
"max_attempts": 8
}A test delivery is a real delivery: it goes through the same queue, the same signature, the same retries. Poll GET /webhook-deliveries/{id} to see the outcome.
#Manage
curl -sS -X PATCH "$BASE/webhooks/whk_01M3PSVK981SXWGKG9JXHC1P0Y" \
-H "Authorization: Bearer $ULEX_API_KEY" -H "Content-Type: application/json" \
-d '{"events":["dsync.user.created","dsync.user.deleted"],"description":"Trimmed 2026-09"}'
curl -sS -X POST "$BASE/webhooks/whk_01M3PSVK981SXWGKG9JXHC1P0Y/disable" -H "Authorization: Bearer $ULEX_API_KEY"
curl -sS -X POST "$BASE/webhooks/whk_01M3PSVK981SXWGKG9JXHC1P0Y/enable" -H "Authorization: Bearer $ULEX_API_KEY"
curl -sS -X DELETE "$BASE/webhooks/whk_01M3PSVK981SXWGKG9JXHC1P0Y" -H "Authorization: Bearer $ULEX_API_KEY"{ "id": "whk_01M3PSVK981SXWGKG9JXHC1P0Y", "object": "webhook", "status": "disabled", "disabled_at": "2026-09-29T16:30:00.000Z", "disabled_reason": "manually disabled" }Pricing is usage-based; there is no plan-based webhook endpoint limit. Delivery retry and payload bounds remain technical service limits.
#Idempotent processing
At-least-once delivery means the same event_id can arrive more than once. Dedupe on event_id, which is identical across every retry of one event.
const seen = new Set<string>();
const MAX = 10_000;
function isDuplicate(eventId: string): boolean {
if (seen.has(eventId)) return true;
seen.add(eventId);
if (seen.size > MAX) seen.delete(seen.values().next().value as string);
return false;
}Events are also not delivered in a guaranteed order. dsync.user.updated may arrive before dsync.user.created after a retry storm. Make your handlers idempotent on the resource id, not on arrival order.
#MCP equivalents
ulex_create_webhook, ulex_list_webhooks, ulex_send_test_webhook, ulex_list_webhook_deliveries, ulex_get_webhook_delivery.
Deeper: Webhooks guide, Webhook receiver with signature verification.