# Overview

Webhooks allow you to receive real-time HTTP notifications when events occur in your KrosAI account.

## Setup

{% stepper %}
{% step %}

### Go to the Webhooks page

Go to **Developers** → **Webhooks** in the Dashboard.
{% endstep %}

{% step %}

### Create a webhook

Click **Create Webhook**.
{% endstep %}

{% step %}

### Enter your endpoint

Enter your endpoint URL.
{% endstep %}

{% step %}

### Select events

Select events to subscribe to.
{% endstep %}

{% step %}

### Save and copy secret

Save and copy the signing secret.
{% endstep %}
{% endstepper %}

## Available Events

| Event                      | Description            |
| -------------------------- | ---------------------- |
| `call.started`             | Call connected         |
| `call.ended`               | Call ended             |
| `call.failed`              | Call failed to connect |
| `call.recording.completed` | Recording available    |
| `transcription.completed`  | Transcript ready       |

## Payload Structure

```json
{
  "id": "evt_abc123",
  "event": "call.ended",
  "timestamp": "2025-01-12T10:30:00Z",
  "data": {
    "call_id": "call_xyz789",
    "from_number": "+2348012345678",
    "to_number": "+14155551234",
    "direction": "outbound",
    "duration": 180,
    "cost_cents": 12,
    "status": "completed"
  }
}
```

## Signature Verification

Verify the `X-Webhook-Signature` header:

```javascript
const crypto = require('crypto');

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

## Retry Policy

| Attempt | Delay      |
| ------- | ---------- |
| 1       | Immediate  |
| 2       | 1 minute   |
| 3       | 5 minutes  |
| 4       | 30 minutes |
| 5       | 2 hours    |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.krosai.com/webhooks/overview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
