> ## Documentation Index
> Fetch the complete documentation index at: https://docs.talkover.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Webhook

> Create a new webhook configuration for an agent

## Overview

Creates a new webhook configuration for an agent. Webhooks allow you to receive real-time notifications when specific events occur during calls.

## Endpoint

<ParamField path="agent_id" type="string" required>
  Agent UUID
</ParamField>

## Request

<RequestField name="name" type="string" required>
  Human-readable name for the webhook (max 255 characters)
</RequestField>

<RequestField name="webhook_url" type="string" required>
  URL where webhook events will be sent (max 500 characters, must be valid URL)
</RequestField>

<RequestField name="webhook_secret" type="string">
  Optional secret for HMAC-SHA256 signature verification (max 255 characters). When set, every webhook delivery includes a signature header you can verify.
</RequestField>

<RequestField name="events" type="array" required>
  Array of event types to subscribe to (minimum 1 event required). Each event must be from the available events list returned by [List Agent Webhooks](/api-reference/endpoints/list-agent-webhooks).
</RequestField>

<RequestField name="timeout" type="integer">
  Request timeout in seconds. Range: `5`–`120`. Default: `30`.
</RequestField>

<RequestField name="max_retries" type="integer">
  Maximum number of retry attempts on delivery failure. Range: `0`–`10`. Default: `3`.
</RequestField>

<RequestField name="enabled" type="boolean">
  Whether the webhook should be active. Default: `true`.
</RequestField>

<RequestField name="http_method" type="string">
  HTTP method used to deliver webhook events. Options: `POST`, `PUT`, `PATCH`. Default: `POST`.
</RequestField>

<RequestField name="authorization_scheme" type="string">
  Authorization scheme applied to outgoing requests. Options: `none`, `bearer`, `basic`, `api_key`, `custom`. Default: `none`.
</RequestField>

<RequestField name="custom_headers" type="array">
  Array of custom HTTP headers to include in every delivery. Each item: `{ "key": "Header-Name", "value": "header-value" }`. Useful for static auth tokens or routing headers required by your endpoint.
</RequestField>

<RequestField name="payload_templates" type="object">
  Optional per-event payload templates. Allows you to override the default payload structure for specific events. Keys are event names; values are template objects supporting variable interpolation (e.g., `{{call.id}}`).
</RequestField>

<RequestExample>
  ```bash theme={null}
  curl -X POST \
    'https://app.talkover.ai/api/v1/agents/9fbef0b7-8d4e-4a08-9207-66c22155721d/webhooks' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Content-Type: application/json' \
    -d '{
      "name": "My Webhook",
      "webhook_url": "https://example.com/webhook",
      "webhook_secret": "optional_secret_for_hmac",
      "events": ["event_phone_call_started", "event_phone_call_ended"],
      "timeout": 30,
      "max_retries": 3,
      "enabled": true
    }'
  ```

  ```javascript theme={null}
  const response = await fetch('https://app.talkover.ai/api/v1/agents/9fbef0b7-8d4e-4a08-9207-66c22155721d/webhooks', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'My Webhook',
      webhook_url: 'https://example.com/webhook',
      webhook_secret: 'optional_secret_for_hmac',
      events: ['event_phone_call_started', 'event_phone_call_ended'],
      timeout: 30,
      max_retries: 3,
      enabled: true
    })
  });
  const data = await response.json();
  ```

  ```php theme={null}
  <?php

  $client = new \GuzzleHttp\Client();
  $response = $client->post('https://app.talkover.ai/api/v1/agents/9fbef0b7-8d4e-4a08-9207-66c22155721d/webhooks', [
      'headers' => [
          'Authorization' => 'Bearer YOUR_TOKEN',
          'Content-Type' => 'application/json',
      ],
      'json' => [
          'name' => 'My Webhook',
          'webhook_url' => 'https://example.com/webhook',
          'webhook_secret' => 'optional_secret_for_hmac',
          'events' => ['event_phone_call_started', 'event_phone_call_ended'],
          'timeout' => 30,
          'max_retries' => 3,
          'enabled' => true
      ],
  ]);
  $data = json_decode($response->getBody());
  ```
</RequestExample>

## Response

<ResponseField name="success" type="boolean">
  Indicates if the webhook was created successfully
</ResponseField>

<ResponseField name="message" type="string">
  Success message
</ResponseField>

<ResponseField name="data" type="object">
  Created webhook object
</ResponseField>

<ResponseField name="data.id" type="string">
  Unique webhook identifier
</ResponseField>

<ResponseField name="data.agent_id" type="string">
  Agent UUID this webhook belongs to
</ResponseField>

<ResponseField name="data.name" type="string">
  Webhook name
</ResponseField>

<ResponseField name="data.webhook_url" type="string">
  Webhook URL
</ResponseField>

<ResponseField name="data.events" type="array">
  Array of configured event types
</ResponseField>

<ResponseField name="data.timeout" type="integer">
  Request timeout in seconds
</ResponseField>

<ResponseField name="data.max_retries" type="integer">
  Maximum retry attempts
</ResponseField>

<ResponseField name="data.enabled" type="boolean">
  Whether webhook is active
</ResponseField>

<ResponseField name="data.created_at" type="string">
  ISO 8601 timestamp when webhook was created
</ResponseField>

<ResponseField name="data.updated_at" type="string">
  ISO 8601 timestamp when webhook was last updated
</ResponseField>

<ResponseField name="data.events_count" type="integer">
  Number of events configured for this webhook
</ResponseField>

<ResponseField name="data.status" type="string">
  Current webhook status
</ResponseField>

<ResponseExample>
  ```json theme={null}
  {
    "success": true,
    "message": "Webhook created successfully",
    "data": {
      "id": "9fcafbf2-7593-44d6-8cd7-1b221beba62a",
      "agent_id": "9fbef0b7-8d4e-4a08-9207-66c22155721d",
      "name": "My Webhook",
      "webhook_url": "https://example.com/webhook",
      "events": ["event_phone_call_started", "event_phone_call_ended"],
      "timeout": 30,
      "max_retries": 3,
      "enabled": true,
      "created_at": "2025-09-03T23:19:51.000000Z",
      "updated_at": "2025-09-03T23:19:51.000000Z",
      "events_count": 2,
      "status": "active"
    }
  }
  ```
</ResponseExample>

## Error responses

<ResponseExample title="401 Unauthorized">
  ```json theme={null}
  {
    "message": "Missing Bearer Token"
  }
  ```
</ResponseExample>

<ResponseExample title="404 Not Found">
  ```json theme={null}
  {
    "success": false,
    "message": "Agent not found in this environment."
  }
  ```
</ResponseExample>

<ResponseExample title="422 Validation Error">
  ```json theme={null}
  {
    "message": "The given data was invalid.",
    "errors": {
      "webhook_url": ["The webhook url field is required."],
      "events": ["The events field must contain at least 1 items."]
    }
  }
  ```
</ResponseExample>

## Validation rules

* **name**: Required, string, maximum 255 characters
* **webhook\_url**: Required, valid URL, maximum 500 characters
* **webhook\_secret**: Optional, string, maximum 255 characters
* **events**: Required, array with minimum 1 event, each event must be from available events list
* **timeout**: Optional, integer between 5-120 seconds (default: 30)
* **max\_retries**: Optional, integer between 0-10 (default: 3)
* **enabled**: Optional, boolean (default: true)

## Important notes

* Webhook operations automatically clear the agent cache for immediate effect
* Use HTTPS endpoints for webhook URLs in production
* Implement proper signature verification using the webhook secret for security
* Test your webhook endpoint before going live using the test endpoint

## Related endpoints

* [List Agent Webhooks](/api-reference/endpoints/list-agent-webhooks) - Get all webhooks for an agent
* [Get Webhook Details](/api-reference/endpoints/get-webhook-details) - Retrieve specific webhook information
* [Update Webhook](/api-reference/endpoints/update-webhook) - Modify webhook configuration
* [Delete Webhook](/api-reference/endpoints/delete-webhook) - Remove webhook configuration
* [Toggle Webhook Status](/api-reference/endpoints/toggle-webhook-status) - Enable/disable webhook
* [Test Webhook](/api-reference/endpoints/test-webhook) - Send test payload to verify connectivity
