SDKsTypeScript SDKAdmin API
Webhook Management
Create, test, and manage webhook endpoints and delivery logs with the TypeScript SDK.
Webhook Management
Configure webhook endpoints to receive real-time notifications when events occur in Avnology ID (user created, session started, organization updated, etc.).
createWebhook()
Register a new webhook endpoint.
client.admin.createWebhook(params: CreateWebhookParams): Promise<Webhook>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
url | string | yes | HTTPS endpoint URL |
events | string[] | yes | Event types to subscribe to |
organizationId | string | no | Scope to a specific organization |
secret | string | no | Signing secret (auto-generated if omitted) |
active | boolean | no | Enable immediately (default: true) |
metadata | Record<string, string> | no | Custom metadata |
Event types
| Event | Description |
|---|---|
user.created | New user registered |
user.updated | User profile changed |
user.deleted | User account deleted |
session.created | New session started |
session.revoked | Session ended |
organization.created | New organization |
organization.updated | Organization settings changed |
organization.member.added | User added to organization |
organization.member.removed | User removed from organization |
oauth.consent.granted | OAuth consent approved |
oauth.consent.revoked | OAuth consent revoked |
mfa.enrolled | MFA method added |
mfa.removed | MFA method removed |
sso.connection.created | SSO connection configured |
directory.sync.completed | SCIM directory sync finished |
Basic usage
const webhook = await client.admin.createWebhook({
url: "https://myapp.com/webhooks/avnology",
events: ["user.created", "user.updated", "user.deleted"],
});
console.log(webhook.id); // "wh_abc123"
console.log(webhook.secret); // "whsec_..." (save this for verification)testWebhook()
Send a test event to verify your endpoint is working.
const result = await client.admin.testWebhook({
webhookId: "wh_abc123",
});
console.log(result.statusCode); // 200
console.log(result.responseBody); // "OK"
console.log(result.durationMs); // 145listDeliveries()
View the delivery log for a webhook.
const deliveries = await client.admin.listWebhookDeliveries({
webhookId: "wh_abc123",
pageSize: 25,
});
for (const delivery of deliveries.deliveries) {
console.log(delivery.id, delivery.event, delivery.status, delivery.statusCode);
// "del_abc123" "user.created" "success" 200
// "del_def456" "user.updated" "failed" 500
}replayDelivery()
Retry a failed webhook delivery.
await client.admin.replayWebhookDelivery({
webhookId: "wh_abc123",
deliveryId: "del_def456",
});rotateSecret()
Rotate the webhook signing secret with a grace period.
const result = await client.admin.rotateWebhookSecret({
webhookId: "wh_abc123",
gracePeriodHours: 24,
});
console.log("New secret:", result.secret);
console.log("Old secret valid for 24 more hours.");Common errors
| Error class | HTTP status | When |
|---|---|---|
NotFoundError | 404 | Webhook not found |
ValidationError | 422 | Invalid URL or events |
ForbiddenError | 403 | Insufficient permissions |
See also
- Webhook verification -- Verify signatures
- Webhook type -- Type definitions