---
title: "Create a webhook"
description: "Creates a webhook that posts an event to your URL. The response includes the signing secret in `secrets`; store it to verify deliveries."
---

**POST** `https://api.respan.ai/api/webhooks/`

Creates a webhook that posts an event to your URL. The response includes the signing secret in `secrets`; store it to verify deliveries.

## Servers

`https://api.respan.ai`: Respan API Server

## Authentication

### RespanApiKey

Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer &lt;RESPAN_API_KEY&gt;. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -&gt; Providers or respan_params.credential_override in the request body, not in this authentication field.

HTTP scheme: `bearer`; format: `Respan API key`.


```http
Authorization: Bearer $RESPAN_API_KEY
```


## Request body

A request body is required.

### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Required body | Reference: `#/components/schemas/WebhookCreateRequest` |
| `name` | `string` | Optional | Display name.<br />Maximum length: `70`<br />Example: `"Log sink"` |
| `url` | `string` | Required in parent | HTTPS endpoint that receives the events.<br />Format: `uri`<br />Maximum length: `200`<br />Example: `"https://example.com/respan/webhook"` |
| `event_type` | `string` | Optional | Event that triggers the webhook.<br />Reference: `#/components/schemas/WebhookEventType`<br />Allowed: `"request_log"`, `"on_eval_result_ingested"`, `"trace_completed"`, `"customer_budget_limit_reached"`, `"credit_low_balance_threshold_reached"`, `"limit_policy_soft_triggered"`, `"limit_policy_hard_triggered"`<br />Default: `request_log`<br />Example: `"request_log"` |
| `active` | `boolean` | Optional | Whether events are sent.<br />Default: `true`<br />Example: `true` |
| `organization_key` | `string or null` | Optional | Only send events for this API key (its ID). `null` sends events for every key.<br />Example: `null` |


<details class="api-schema-source">
<summary>OpenAPI request schema</summary>


```json
{
  "$ref": "#/components/schemas/WebhookCreateRequest"
}
```

</details>

##### Example


```json
{
  "name": "Log sink",
  "url": "https://example.com/respan/webhook",
  "event_type": "request_log"
}
```


## Examples

### Create a webhook

#### Headers


```json
{
  "Authorization": "Bearer YOUR_RESPAN_API_KEY"
}
```


#### Request


```json
{
  "name": "Log sink",
  "url": "https://example.com/respan/webhook",
  "event_type": "request_log"
}
```


#### Response


```json
{
  "body": {
    "id": 25,
    "name": "Log sink",
    "url": "https://example.com/respan/webhook",
    "event_type": "request_log",
    "active": true,
    "organization_key": null,
    "organization_key_name": null,
    "project": "36253bba-bb22-40f9-9f83-c87baac9a833",
    "created": "2026-11-23T01:00:00Z",
    "secrets": "whsec_3f9a..."
  }
}
```


## Responses

### 201

The created webhook, with its secret.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object and object` | Body | Reference: `#/components/schemas/WebhookWithSecret` |
| `$ (allOf 1)` | `object` | Schema variant | Reference: `#/components/schemas/Webhook` |
| `$ (allOf 1).id` | `integer` | Required in parent | Webhook ID.<br />Read only<br />Example: `25` |
| `$ (allOf 1).name` | `string` | Optional | Display name.<br />Maximum length: `70`<br />Example: `"Log sink"` |
| `$ (allOf 1).url` | `string` | Required in parent | HTTPS endpoint that receives the events.<br />Format: `uri`<br />Maximum length: `200`<br />Example: `"https://example.com/respan/webhook"` |
| `$ (allOf 1).event_type` | `string` | Optional | Event that triggers the webhook.<br />Reference: `#/components/schemas/WebhookEventType`<br />Allowed: `"request_log"`, `"on_eval_result_ingested"`, `"trace_completed"`, `"customer_budget_limit_reached"`, `"credit_low_balance_threshold_reached"`, `"limit_policy_soft_triggered"`, `"limit_policy_hard_triggered"`<br />Default: `request_log`<br />Example: `"request_log"` |
| `$ (allOf 1).active` | `boolean` | Optional | Whether events are sent.<br />Default: `true`<br />Example: `true` |
| `$ (allOf 1).organization_key` | `string or null` | Optional | Only send events for this API key (its ID). `null` sends events for every key.<br />Example: `null` |
| `$ (allOf 1).organization_key_name` | `string or null` | Optional | Name of the linked API key.<br />Read only<br />Example: `null` |
| `$ (allOf 1).project` | `string or null` | Optional | Project ID.<br />Read only<br />Example: `"36253bba-bb22-40f9-9f83-c87baac9a833"` |
| `$ (allOf 1).created` | `string` | Optional | Format: `date-time`<br />Read only<br />Example: `"2026-11-23T01:00:00Z"` |
| `$ (allOf 2)` | `object` | Schema variant | - |
| `$ (allOf 2).secrets` | `string` | Required in parent | Signing secret for verifying deliveries. Returned on create, and on get with `is_including_secrets=true`.<br />Read only<br />Example: `"whsec_3f9a..."` |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "$ref": "#/components/schemas/WebhookWithSecret"
}
```

</details>

##### Example


```json
{
  "id": 25,
  "name": "Log sink",
  "url": "https://example.com/respan/webhook",
  "event_type": "request_log",
  "active": true,
  "organization_key": null,
  "organization_key_name": null,
  "project": "36253bba-bb22-40f9-9f83-c87baac9a833",
  "created": "2026-11-23T01:00:00Z",
  "secrets": "whsec_3f9a..."
}
```


### 400

Validation failed. The body maps each invalid field to its errors.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `$.<key>` | `any` | Map value | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "additionalProperties": {}
}
```

</details>

##### Example


```json
{
  "url": [
    "Enter a valid URL."
  ]
}
```


### 403

The API key is missing, invalid or expired.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Required in parent | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "detail"
  ],
  "properties": {
    "detail": {
      "type": "string"
    }
  }
}
```

</details>

##### Example


```json
{
  "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}
```


## OpenAPI source

The operation and referenced components below retain the complete OpenAPI definitions, including constraints and examples.

<!-- openapi-operation:start -->
<details class="api-schema-source">
<summary>OpenAPI operation</summary>


```json
{
  "summary": "Create a webhook",
  "operationId": "createWebhook",
  "tags": [
    "Webhooks"
  ],
  "description": "Creates a webhook that posts an event to your URL. The response includes the signing secret in `secrets`; store it to verify deliveries.",
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/WebhookCreateRequest"
        },
        "example": {
          "name": "Log sink",
          "url": "https://example.com/respan/webhook",
          "event_type": "request_log"
        }
      }
    }
  },
  "responses": {
    "201": {
      "description": "The created webhook, with its secret.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/WebhookWithSecret"
          },
          "example": {
            "id": 25,
            "name": "Log sink",
            "url": "https://example.com/respan/webhook",
            "event_type": "request_log",
            "active": true,
            "organization_key": null,
            "organization_key_name": null,
            "project": "36253bba-bb22-40f9-9f83-c87baac9a833",
            "created": "2026-11-23T01:00:00Z",
            "secrets": "whsec_3f9a..."
          }
        }
      }
    },
    "400": {
      "description": "Validation failed. The body maps each invalid field to its errors.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "additionalProperties": {}
          },
          "example": {
            "url": [
              "Enter a valid URL."
            ]
          }
        }
      }
    },
    "403": {
      "$ref": "#/components/responses/InvalidApiKey"
    }
  },
  "security": [
    {
      "RespanApiKey": []
    }
  ],
  "x-fern-examples": [
    {
      "name": "Create a webhook",
      "headers": {
        "Authorization": "Bearer YOUR_RESPAN_API_KEY"
      },
      "request": {
        "name": "Log sink",
        "url": "https://example.com/respan/webhook",
        "event_type": "request_log"
      },
      "response": {
        "body": {
          "id": 25,
          "name": "Log sink",
          "url": "https://example.com/respan/webhook",
          "event_type": "request_log",
          "active": true,
          "organization_key": null,
          "organization_key_name": null,
          "project": "36253bba-bb22-40f9-9f83-c87baac9a833",
          "created": "2026-11-23T01:00:00Z",
          "secrets": "whsec_3f9a..."
        }
      }
    }
  ]
}
```

</details>
<!-- openapi-operation:end -->

<!-- openapi-path-item:start -->
<details class="api-schema-source">
<summary>OpenAPI path metadata</summary>


```json
{}
```

</details>
<!-- openapi-path-item:end -->

<!-- openapi-components:start -->
<details class="api-schema-source">
<summary>Referenced OpenAPI components</summary>


```json
{
  "responses": {
    "InvalidApiKey": {
      "description": "The API key is missing, invalid or expired.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "detail"
            ],
            "properties": {
              "detail": {
                "type": "string"
              }
            }
          },
          "example": {
            "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
          }
        }
      }
    }
  },
  "schemas": {
    "Webhook": {
      "type": "object",
      "required": [
        "id",
        "url"
      ],
      "properties": {
        "id": {
          "type": "integer",
          "readOnly": true,
          "description": "Webhook ID.",
          "example": 25
        },
        "name": {
          "type": "string",
          "maxLength": 70,
          "description": "Display name.",
          "example": "Log sink"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "maxLength": 200,
          "description": "HTTPS endpoint that receives the events.",
          "example": "https://example.com/respan/webhook"
        },
        "event_type": {
          "$ref": "#/components/schemas/WebhookEventType"
        },
        "active": {
          "type": "boolean",
          "default": true,
          "description": "Whether events are sent.",
          "example": true
        },
        "organization_key": {
          "type": "string",
          "nullable": true,
          "description": "Only send events for this API key (its ID). `null` sends events for every key.",
          "example": null
        },
        "organization_key_name": {
          "type": "string",
          "nullable": true,
          "readOnly": true,
          "description": "Name of the linked API key.",
          "example": null
        },
        "project": {
          "type": "string",
          "nullable": true,
          "readOnly": true,
          "description": "Project ID.",
          "example": "36253bba-bb22-40f9-9f83-c87baac9a833"
        },
        "created": {
          "type": "string",
          "format": "date-time",
          "readOnly": true,
          "example": "2026-11-23T01:00:00Z"
        }
      }
    },
    "WebhookCreateRequest": {
      "type": "object",
      "required": [
        "url"
      ],
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 70,
          "description": "Display name.",
          "example": "Log sink"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "maxLength": 200,
          "description": "HTTPS endpoint that receives the events.",
          "example": "https://example.com/respan/webhook"
        },
        "event_type": {
          "$ref": "#/components/schemas/WebhookEventType"
        },
        "active": {
          "type": "boolean",
          "default": true,
          "description": "Whether events are sent.",
          "example": true
        },
        "organization_key": {
          "type": "string",
          "nullable": true,
          "description": "Only send events for this API key (its ID). `null` sends events for every key.",
          "example": null
        }
      }
    },
    "WebhookEventType": {
      "type": "string",
      "enum": [
        "request_log",
        "on_eval_result_ingested",
        "trace_completed",
        "customer_budget_limit_reached",
        "credit_low_balance_threshold_reached",
        "limit_policy_soft_triggered",
        "limit_policy_hard_triggered"
      ],
      "default": "request_log",
      "description": "Event that triggers the webhook.",
      "example": "request_log"
    },
    "WebhookWithSecret": {
      "allOf": [
        {
          "$ref": "#/components/schemas/Webhook"
        },
        {
          "type": "object",
          "required": [
            "secrets"
          ],
          "properties": {
            "secrets": {
              "type": "string",
              "readOnly": true,
              "description": "Signing secret for verifying deliveries. Returned on create, and on get with `is_including_secrets=true`.",
              "example": "whsec_3f9a..."
            }
          }
        }
      ]
    }
  },
  "securitySchemes": {
    "RespanApiKey": {
      "type": "http",
      "scheme": "bearer",
      "bearerFormat": "Respan API key",
      "description": "Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.",
      "x-fern-bearer": {
        "name": "respanApiKey",
        "env": "RESPAN_API_KEY"
      }
    }
  }
}
```

</details>
<!-- openapi-components:end -->
