Skip to content

Webhook Management

Overview

The Webhook Management API provides endpoints for configuring and managing webhook endpoints for event notifications. You can notify external systems of events such as user creation, login, and role changes.

Endpoint List

MethodEndpointDescription
GET/api/admin/webhooksList webhooks
GET/api/admin/webhooks/:idGet webhook details
POST/api/admin/webhooksCreate webhook
PUT/api/admin/webhooks/:idUpdate webhook
DELETE/api/admin/webhooks/:idDelete webhook
POST/api/admin/webhooks/:id/testTest webhook
GET/api/admin/webhooks/:id/deliveriesGet delivery history
POST/api/admin/webhooks/:id/deliveries/:deliveryId/retryRetry delivery

List Webhooks

Retrieve a list of configured webhooks.

Endpoint

GET /api/admin/webhooks

Query Parameters

ParameterTypeRequiredDescription
limitinteger-Number of items (default: 20)
cursorstring-Pagination cursor
statusstring-Filter by status (active, inactive)

Request Example

Terminal window
curl -X GET "https://{tenant-domain}/api/admin/webhooks" \
-H "Authorization: Bearer {token}"

Response Example

{
"items": [
{
"id": "webhook_abc123",
"name": "User Events",
"url": "https://api.example.com/webhooks/authrim",
"events": ["user.created", "user.updated", "user.deleted"],
"status": "active",
"success_rate": 99.5,
"last_triggered_at": 1706054400,
"created_at": 1705881600
}
],
"total": 3
}

Get Webhook Details

Retrieve detailed information for a specified webhook.

Endpoint

GET /api/admin/webhooks/:id

Path Parameters

ParameterTypeRequiredDescription
idstringWebhook ID

Request Example

Terminal window
curl -X GET "https://{tenant-domain}/api/admin/webhooks/webhook_abc123" \
-H "Authorization: Bearer {token}"

Response Example

{
"id": "webhook_abc123",
"name": "User Events",
"description": "User-related event notifications",
"url": "https://api.example.com/webhooks/authrim",
"events": ["user.created", "user.updated", "user.deleted"],
"status": "active",
"headers": {
"X-Custom-Header": "custom-value"
},
"timeout": 30,
"retry_policy": {
"max_retries": 3,
"retry_interval": 60
},
"filters": {
"user.created": {
"roles": ["admin"]
}
},
"success_rate": 99.5,
"total_deliveries": 1250,
"failed_deliveries": 6,
"last_triggered_at": 1706054400,
"last_success_at": 1706054400,
"last_failure_at": 1705968000,
"created_at": 1705881600,
"updated_at": 1706054400
}

Create Webhook

Create a new webhook.

Endpoint

POST /api/admin/webhooks

Request Body

FieldTypeRequiredDescription
namestringWebhook name
urlstringEndpoint URL
eventsstring[]Events to subscribe to
descriptionstring-Description
secretstring-Secret for signing
headersobject-Custom headers
timeoutinteger-Timeout in seconds (default: 30)
retry_policyobject-Retry policy
filtersobject-Event filters

Request Example

Terminal window
curl -X POST "https://{tenant-domain}/api/admin/webhooks" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"name": "Security Events",
"url": "https://siem.example.com/webhooks/authrim",
"events": ["auth.login", "auth.login_failed", "auth.logout", "security.alert"],
"secret": "webhook_secret_123",
"headers": {
"X-Source": "authrim"
},
"retry_policy": {
"max_retries": 5,
"retry_interval": 30
}
}'

Response Example

{
"id": "webhook_xyz789",
"name": "Security Events",
"url": "https://siem.example.com/webhooks/authrim",
"events": ["auth.login", "auth.login_failed", "auth.logout", "security.alert"],
"status": "active",
"created_at": 1706140800
}

Update Webhook

Update an existing webhook.

Endpoint

PUT /api/admin/webhooks/:id

Request Example

Terminal window
curl -X PUT "https://{tenant-domain}/api/admin/webhooks/webhook_abc123" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"events": ["user.created", "user.updated", "user.deleted", "user.suspended"],
"status": "active"
}'

Delete Webhook

Delete a webhook.

Endpoint

DELETE /api/admin/webhooks/:id

Request Example

Terminal window
curl -X DELETE "https://{tenant-domain}/api/admin/webhooks/webhook_abc123" \
-H "Authorization: Bearer {token}"

Test Webhook

Test the webhook configuration. A test event will be sent.

Endpoint

POST /api/admin/webhooks/:id/test

Request Body

FieldTypeRequiredDescription
eventstring-Event type to test

Request Example

Terminal window
curl -X POST "https://{tenant-domain}/api/admin/webhooks/webhook_abc123/test" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"event": "user.created"
}'

Response Example (Success)

{
"success": true,
"response_status": 200,
"response_time_ms": 150,
"response_body": "{\"received\": true}"
}

Response Example (Failure)

{
"success": false,
"error": "Connection timeout",
"response_time_ms": 30000
}

Get Delivery History

Retrieve webhook delivery history.

Endpoint

GET /api/admin/webhooks/:id/deliveries

Query Parameters

ParameterTypeRequiredDescription
limitinteger-Number of items (default: 50)
cursorstring-Pagination cursor
statusstring-Filter by status (success, failed, pending)
eventstring-Filter by event type

Request Example

Terminal window
curl -X GET "https://{tenant-domain}/api/admin/webhooks/webhook_abc123/deliveries?status=failed" \
-H "Authorization: Bearer {token}"

Response Example

{
"items": [
{
"id": "delivery_abc123",
"event": "user.created",
"status": "failed",
"attempt": 3,
"response_status": 500,
"response_time_ms": 2500,
"error": "Internal Server Error",
"request_body": {
"event": "user.created",
"timestamp": "2024-01-22T10:30:00Z",
"data": {
"user_id": "usr_xyz789"
}
},
"triggered_at": 1706054400,
"completed_at": 1706054403
}
],
"total": 6,
"cursor": null
}

Retry Delivery

Manually retry a failed delivery.

Endpoint

POST /api/admin/webhooks/:id/deliveries/:deliveryId/retry

Path Parameters

ParameterTypeRequiredDescription
idstringWebhook ID
deliveryIdstringDelivery ID

Request Example

Terminal window
curl -X POST "https://{tenant-domain}/api/admin/webhooks/webhook_abc123/deliveries/delivery_abc123/retry" \
-H "Authorization: Bearer {token}"

Response Example

{
"id": "delivery_abc123",
"status": "pending",
"retry_at": 1706140800
}

Event List

User Events

EventDescription
user.createdUser created
user.updatedUser updated
user.deletedUser deleted
user.suspendedUser suspended
user.unsuspendedUser unsuspended

Authentication Events

EventDescription
auth.loginLogin success
auth.login_failedLogin failed
auth.logoutLogout
auth.password_changedPassword changed
auth.mfa_enabledMFA enabled

Security Events

EventDescription
security.alertSecurity alert
security.suspicious_activitySuspicious activity

Role & Permission Events

EventDescription
role.assignedRole assigned
role.unassignedRole unassigned
policy.createdPolicy created
policy.updatedPolicy updated

Webhook Signature

Webhook requests include signature headers:

X-Authrim-Signature: sha256=xxxxxxxxxxxxxxxxxxxx
X-Authrim-Timestamp: 1706140800

Signature verification:

const crypto = require('crypto');
function verifySignature(payload, signature, secret, timestamp) {
const signedPayload = `${timestamp}.${payload}`;
const expectedSignature = crypto
.createHmac('sha256', secret)
.update(signedPayload)
.digest('hex');
return `sha256=${expectedSignature}` === signature;
}