Webhooks Overview
Webhooks allow you to receive real-time notifications when events occur in your Klen AI account. Instead of polling our API, your server can be notified automatically when events like calls, transcripts, recordings, or calendar events become available.How Webhooks Work
- You create a webhook endpoint on your server that can receive HTTP POST requests.
- You register this endpoint URL with Klen AI and specify which events you want to subscribe to.
- When an event occurs in your account, Klen AI sends an HTTP POST request to your endpoint with event data in JSON format.
- Your server processes the incoming webhook data and takes appropriate actions.
Creating a Webhook Endpoint
From the Dashboard
- Log in to your Klen AI dashboard
- Navigate to API > Webhooks
- Click “Create New Webhook”
- Enter a name, your endpoint URL, and select the events you want to subscribe to
- Copy the generated secret for signature verification
Via the API
You can also create webhooks programmatically via our API:Available Events
Call Events
Event Name | Description |
---|---|
call.started | Triggered when a call begins |
call.ended | Triggered when a call ends |
call.failed | Triggered when a call fails to connect |
call.transcript | Triggered when a call transcript becomes available |
call.recording | Triggered when a call recording becomes available |
call.summary | Triggered when a call summary becomes available |
Calendar Events
Event Name | Description |
---|---|
calendar.created | Triggered when a calendar event is created |
calendar.updated | Triggered when a calendar event is updated |
calendar.cancelled | Triggered when a calendar event is cancelled |
calendar.completed | Triggered when a calendar event is completed |
calendar.reminder | Triggered when a reminder for a calendar event is sent |
Webhook Payload Structure
Call Event Payload
Call event webhooks follow this general structure:Calendar Event Payload
Calendar event webhooks follow this general structure:Verifying Webhook Signatures
For security, we sign all webhook requests with a signature that you can verify to ensure the request came from Klen AI:- When you create a webhook, you receive a secret.
- We include a signature in the
X-Klen-Signature
header of each webhook request. - You can verify this signature by creating an HMAC-SHA256 hash of the request body using your webhook secret.
Handling Webhook Deliveries
Best Practices
- Process webhooks asynchronously: Respond quickly to the webhook request (with a 200 status code) and process the data in the background.
-
Implement idempotency: Use the
X-Klen-Delivery-ID
header to ensure you don’t process the same webhook multiple times. - Verify signatures: Always verify the webhook signature to ensure the request came from Klen AI.
- Handle timeouts: We expect your endpoint to respond within 10 seconds. Process data asynchronously if needed.
- Implement proper error handling: If your endpoint fails to process a webhook, we’ll retry with exponential backoff (1 minute, 5 minutes, 30 minutes).
Example Webhook Handler (Express.js)
Retries and Failures
If your endpoint fails to respond, Klen AI will retry the webhook delivery with the following schedule:- First retry: After 1 minute
- Second retry: After 5 minutes
- Final retry: After 30 minutes
Managing Webhooks
You can view, update, and delete webhooks from your Klen AI dashboard or via our API:- List webhooks:
GET /api/v1/webhooks
- Get webhook details:
GET /api/v1/webhooks/{webhook_id}
- Delete webhook:
POST /api/v1/webhooks/{webhook_id}/delete