Skip to Content
Referência da APIAPI de Webhooks

Webhooks API

Webhooks allow your application to receive real-time HTTP callbacks when events occur in Auris. When a subscribed event fires (e.g., a user logs in, a role is assigned, an account is locked), Auris sends a POST request to your configured URL with a JSON payload describing the event.

Every webhook delivery is signed with HMAC-SHA256 using a per-webhook signing secret. This allows your server to verify that the payload originated from Auris and was not tampered with in transit.

All webhook management endpoints require the manage:webhooks permission and the x-tenant header.

Webhook CRUD

List Webhooks

GET/api/webhooksRequires: manage:webhooks

List all webhook endpoints configured for the tenant. Returns webhook metadata including the subscribed events, active status, and failure statistics. The signing secret is never returned in list responses.

Query parameters

ParameterTypeDescription
pageintegerPage number (default: 1)
limitintegerItems per page (default: 20)

Success response

{ "ok": true, "data": { "data": [ { "id": "whk_abc123", "name": "Production Event Handler", "url": "https://api.yourapp.com/webhooks/auris", "events": ["user.created", "user.updated", "login.success", "login.failed"], "isActive": true, "lastDeliveryAt": "2025-02-18T09:45:00Z", "failureCount": 0, "createdAt": "2025-01-15T10:00:00Z" } ], "pagination": { "page": 1, "limit": 20, "total": 3, "totalPages": 1 } } }

Create Webhook

POST/api/webhooksRequires: manage:webhooks

Create a new webhook endpoint. A signing secret is automatically generated with a whsec_ prefix. The secret is returned only in the creation response — store it securely, as it cannot be retrieved later (only rotated).

Request body

{ "name": "Production Event Handler", "url": "https://api.yourapp.com/webhooks/auris", "events": ["user.created", "user.updated", "user.deleted", "login.success"] }
FieldTypeRequiredDescription
namestringYesHuman-readable name for this webhook
urlstringYesHTTPS endpoint URL that will receive POST requests
eventsstring[]YesArray of event types to subscribe to (see Event Types)

Webhook URLs must use HTTPS. HTTP URLs are rejected to prevent secrets and user data from being transmitted in plaintext.

Success response

{ "ok": true, "data": { "id": "whk_def456", "name": "Production Event Handler", "url": "https://api.yourapp.com/webhooks/auris", "events": ["user.created", "user.updated", "user.deleted", "login.success"], "secret": "whsec_7f3a8b2c4d5e6f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f", "isActive": true, "createdAt": "2025-02-18T10:00:00Z" } }

The secret field is only returned in the creation response and after secret rotation. Copy and store it immediately in a secure location (e.g., environment variable or secrets manager). It cannot be retrieved again.

Error codes

CodeHTTPDescription
VALIDATION_ERROR400Missing required fields or invalid event types
INVALID_URL400URL is not a valid HTTPS endpoint
INVALID_EVENTS400One or more event type strings are not recognized

Get Webhook

GET/api/webhooks/[id]Requires: manage:webhooks

Retrieve a single webhook by ID. Returns full webhook details excluding the signing secret.

Success response

{ "ok": true, "data": { "id": "whk_abc123", "name": "Production Event Handler", "url": "https://api.yourapp.com/webhooks/auris", "events": ["user.created", "user.updated", "login.success", "login.failed"], "isActive": true, "failureCount": 0, "lastDeliveryAt": "2025-02-18T09:45:00Z", "createdAt": "2025-01-15T10:00:00Z", "updatedAt": "2025-02-10T14:00:00Z" } }

Update Webhook

PATCH/api/webhooks/[id]Requires: manage:webhooks

Update a webhook’s name, URL, subscribed events, or active status. All fields are optional — only provided fields are updated.

Request body

{ "name": "Production Event Handler v2", "events": ["user.created", "user.updated", "user.deleted", "login.success", "login.failed", "role.assigned"], "isActive": true }

Success response

{ "ok": true, "data": { "id": "whk_abc123", "name": "Production Event Handler v2", "url": "https://api.yourapp.com/webhooks/auris", "events": ["user.created", "user.updated", "user.deleted", "login.success", "login.failed", "role.assigned"], "isActive": true, "updatedAt": "2025-02-18T11:00:00Z" } }

Delete Webhook

DELETE/api/webhooks/[id]Requires: manage:webhooks

Delete a webhook endpoint. Pending deliveries for this webhook are cancelled. Delivery history is retained for audit purposes.

Success response

{ "ok": true, "data": { "deleted": true } }

Secret Rotation

POST/api/webhooks/[id]/rotate-secretRequires: manage:webhooks

Generate a new signing secret for the webhook. The old secret is immediately invalidated. The new secret is returned in the response. All subsequent deliveries will be signed with the new secret.

Request: No body required.

Success response

{ "ok": true, "data": { "secret": "whsec_9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d3e2f1a0b9c8d7e6f5a4b3c2d1e0f9a" } }

After rotating a secret, update your webhook handler to use the new secret immediately. Deliveries in-flight at the moment of rotation may still use the old secret. Best practice: support verifying against both old and new secrets for a short grace period during rotation.

Testing

POST/api/webhooks/[id]/testRequires: manage:webhooks

Send a test delivery to the webhook URL. Auris sends a webhook.test event with a sample payload. The delivery is recorded in the delivery log. Use this to verify your endpoint is reachable and correctly verifying signatures.

Request: No body required.

Success response

{ "ok": true, "data": { "deliveryId": "del_xyz789", "statusCode": 200, "success": true, "responseTime": 142 } }

Test event payload (what your endpoint receives)

{ "event": "webhook.test", "timestamp": "2025-02-18T10:30:00Z", "tenant": "acme-corp", "data": { "message": "This is a test delivery from Auris.", "webhookId": "whk_abc123" } }

Error codes

CodeHTTPDescription
DELIVERY_FAILED502The webhook endpoint returned a non-2xx status code
ENDPOINT_UNREACHABLE502Could not connect to the webhook URL (DNS failure, timeout, etc.)

Delivery Log

List Deliveries

GET/api/webhooks/[id]/deliveriesRequires: manage:webhooks

List delivery attempts for a webhook, ordered by timestamp descending. Each delivery includes the event type, HTTP status code, response time, and whether the delivery was successful. Retried deliveries are separate entries linked to the same event.

Query parameters

ParameterTypeDescription
pageintegerPage number (default: 1)
limitintegerItems per page (default: 20)

Success response

{ "ok": true, "data": { "data": [ { "id": "del_abc123", "event": "user.created", "statusCode": 200, "success": true, "responseTime": 89, "attempts": 1, "payload": { "event": "user.created", "timestamp": "2025-02-18T09:45:00Z", "tenant": "acme-corp", "data": { "userId": "usr_abc123", "email": "[email protected]" } }, "createdAt": "2025-02-18T09:45:00Z", "completedAt": "2025-02-18T09:45:01Z" }, { "id": "del_def456", "event": "login.failed", "statusCode": 500, "success": false, "responseTime": 2034, "attempts": 3, "error": "Server returned 500 Internal Server Error", "payload": { "event": "login.failed", "timestamp": "2025-02-18T09:30:00Z", "tenant": "acme-corp", "data": { "email": "[email protected]", "reason": "INVALID_CREDENTIALS", "ipAddress": "203.0.113.50" } }, "createdAt": "2025-02-18T09:30:00Z", "completedAt": "2025-02-18T09:35:12Z" } ], "pagination": { "page": 1, "limit": 20, "total": 156, "totalPages": 8 } } }

Retry Delivery

POST/api/webhooks/[id]/deliveries/[deliveryId]/retryRequires: manage:webhooks

Manually retry a failed delivery. The original payload is re-sent with a new signature. Creates a new delivery entry linked to the same event.

Request: No body required.

Success response

{ "ok": true, "data": { "deliveryId": "del_ghi789", "statusCode": 200, "success": true, "responseTime": 95 } }

Error codes

CodeHTTPDescription
NOT_FOUND404Delivery does not exist
ALREADY_SUCCESSFUL400The delivery was already successful and does not need retrying

Event Types

Auris emits the following webhook events. Subscribe to the events relevant to your use case.

Authentication Events

EventDescription
login.successUser successfully authenticated (any method)
login.failedAuthentication attempt failed (wrong credentials, locked account, etc.)
signup.completedNew user account registered
logout.completedUser logged out (session invalidated)
token.refreshedAccess token was refreshed
password.changedUser changed their password
password.reset_requestedPassword reset email was sent
magic_link.sentMagic link email was sent
magic_link.verifiedMagic link was used to authenticate

User Management Events

EventDescription
user.createdNew user account created (via admin API or signup)
user.updatedUser profile fields were modified
user.deletedUser account was soft-deleted
user.enabledPreviously disabled user was re-enabled
user.disabledUser account was disabled
user.email_verifiedUser verified their email address

Role & Permission Events

EventDescription
role.createdNew role created
role.updatedRole metadata or permissions modified
role.deletedRole deleted
role.assignedRole assigned to a user
role.unassignedRole removed from a user

Security Events

EventDescription
mfa.enabledUser enabled a 2FA method (TOTP, SMS, or WebAuthn)
mfa.disabledUser disabled a 2FA method
account.lockedAccount was locked due to brute-force detection
account.unlockedAccount lock was cleared
suspicious_login.detectedSuspicious login activity detected (new device, impossible travel, etc.)

Organization Events

EventDescription
organization.createdNew organization created
organization.updatedOrganization metadata modified
organization.member_addedUser was added to an organization
organization.member_removedUser was removed from an organization
organization.invitation_sentInvitation email sent

System Events

EventDescription
webhook.testTest delivery triggered via the Console or API

Webhook Payload Format

Every webhook delivery sends a POST request with a JSON body:

{ "event": "user.created", "timestamp": "2025-02-18T10:00:00Z", "tenant": "acme-corp", "data": { "userId": "usr_abc123", "email": "[email protected]", "firstName": "Alice", "lastName": "Smith" } }
FieldTypeDescription
eventstringThe event type (e.g., user.created)
timestampstringISO 8601 timestamp of when the event occurred
tenantstringTenant identifier where the event occurred
dataobjectEvent-specific payload data

The shape of data varies by event type. User events include user fields, role events include role details, and login events include the email and IP address.

Signature Verification

Every delivery includes two headers for signature verification:

HeaderDescription
X-Webhook-SignatureHMAC-SHA256 signature of the request body
X-Webhook-TimestampUnix timestamp (seconds) of when the signature was generated

Verification Algorithm

  1. Read the raw request body as a UTF-8 string (do not parse JSON first).
  2. Read the X-Webhook-Timestamp header.
  3. Concatenate: timestamp + "." + body
  4. Compute HMAC-SHA256 of the concatenated string using your webhook’s signing secret.
  5. Compare the hex-encoded result with the X-Webhook-Signature header using a timing-safe comparison.
  6. Optionally, reject deliveries where the timestamp is more than 5 minutes old (to prevent replay attacks).

Node.js Verification Example

import crypto from 'crypto'; function verifyWebhookSignature(rawBody, signature, timestamp, secret) { // 1. Check timestamp freshness (optional but recommended) const currentTime = Math.floor(Date.now() / 1000); if (Math.abs(currentTime - parseInt(timestamp)) > 300) { throw new Error('Webhook timestamp is too old'); } // 2. Compute expected signature const signedPayload = `${timestamp}.${rawBody}`; const expectedSignature = crypto .createHmac('sha256', secret) .update(signedPayload) .digest('hex'); // 3. Timing-safe comparison const expected = Buffer.from(expectedSignature, 'hex'); const received = Buffer.from(signature, 'hex'); if (expected.length !== received.length) { return false; } return crypto.timingSafeEqual(expected, received); } // Express.js handler app.post('/webhooks/auris', express.raw({ type: 'application/json' }), (req, res) => { const signature = req.headers['x-webhook-signature']; const timestamp = req.headers['x-webhook-timestamp']; const rawBody = req.body.toString('utf-8'); if (!verifyWebhookSignature(rawBody, signature, timestamp, process.env.AURIS_WEBHOOK_SECRET)) { return res.status(401).json({ error: 'Invalid signature' }); } const event = JSON.parse(rawBody); console.log(`Received ${event.event}:`, event.data); // Process the event... res.status(200).json({ received: true }); });

Python Verification Example

import hmac import hashlib import time def verify_webhook_signature(raw_body: bytes, signature: str, timestamp: str, secret: str) -> bool: # Check timestamp freshness current_time = int(time.time()) if abs(current_time - int(timestamp)) > 300: return False # Compute expected signature signed_payload = f"{timestamp}.{raw_body.decode('utf-8')}" expected = hmac.new( secret.encode('utf-8'), signed_payload.encode('utf-8'), hashlib.sha256 ).hexdigest() # Timing-safe comparison return hmac.compare_digest(expected, signature)

The @auris/js SDK includes a built-in webhook verification utility: import { verifyWebhookSignature } from '@auris/js'. It handles timestamp validation, HMAC computation, and timing-safe comparison. See the SDK documentation for details.

Delivery Behavior

Timeouts

Auris waits up to 30 seconds for a response from your webhook endpoint. If your endpoint does not respond within this window, the delivery is marked as failed.

Retry Policy

Failed deliveries are retried with exponential backoff:

AttemptDelay
1st retry1 minute
2nd retry5 minutes
3rd retry30 minutes

After 3 failed retry attempts, the delivery is marked as permanently failed. It can still be manually retried via the API or Console.

Automatic Disabling

If a webhook accumulates 10 consecutive failures (across any deliveries), it is automatically deactivated (isActive: false). You will need to fix the endpoint and manually re-enable the webhook via PATCH /api/webhooks/[id] with { "isActive": true }.

Idempotency

Your webhook handler should be idempotent. In rare cases (network issues, retries), the same event may be delivered more than once. Use the timestamp and event fields to deduplicate if needed.

Best Practices

  1. Respond quickly: Return a 2xx status code as soon as possible. Process the event asynchronously (e.g., queue it) rather than doing heavy work in the request handler.
  2. Verify signatures: Always verify the HMAC-SHA256 signature before processing the payload. Never trust a webhook payload without verification.
  3. Use HTTPS: Auris rejects non-HTTPS webhook URLs. Use a valid TLS certificate.
  4. Handle retries: Design your handler to be idempotent. The same event may be delivered more than once.
  5. Rotate secrets periodically: Use the rotate-secret endpoint to generate a new signing secret on a regular schedule (e.g., quarterly).
  6. Monitor deliveries: Check the delivery log in the Console or via the API to ensure your endpoint is healthy.