# Create a webhook endpoint

`POST /v1/webhook-endpoints`

Required scope: `webhooks:write`

Have events sent to an `https://` URL. `events` lists the event types to send (`contact.stage_changed`, `meeting.booked`, `message.received`, `recording.analyzed`), or `["*"]` for all. The answer carries the signing secret (`whsec_…`) this once: every delivery has a `Valeron-Signature: t=<unix seconds>,v1=<signature>` header, where the signature is the hex HMAC-SHA256 of `<t>.<raw body>` keyed by the secret. Check it, and refuse a `t` more than 5 minutes old. A `2xx` within 10 seconds is success; otherwise the delivery is tried again 1 minute, 5 and 30 minutes, and 2, 5, 10 and 24 hours after the event. An endpoint whose deliveries all fail for 3 days is switched off and the Owner is told. Order is not guaranteed: use the event `id` to ignore a repeat and the object's `updated_at` to ignore an older state. At most 10 endpoints (`409 webhook_endpoint_limit`).

## Request body (application/json)

- `description` (string or null, optional)
- `events` (string[], required) Allowed values: `"*"`, `"recording.analyzed"`, `"contact.stage_changed"`, `"contact.created"`, `"contact.updated"`, `"meeting.booked"`, `"message.received"`, `"payment.succeeded"`.
- `url` (string, required)

## Responses

- `201`: Successful Response
- `400`: The request is not valid.
- `401`: Not signed in, or the credentials are not valid.
- `402`: The balance is too low.
- `403`: Not allowed to do this.
- `404`: Not found.
- `409`: Conflicts with the current state.
- `413`: The request body is too large.
- `415`: The content type is not supported.
- `422`: A value in the request is not valid.
- `429`: Too many requests. Wait for `Retry-After` seconds.
- `500`: Something went wrong on our side.
- `502`: A service Valeron depends on refused the request.
- `503`: A service Valeron depends on is unavailable.

## Examples

### Request

```bash title="cURL"
curl -X POST "https://api.valeron.io/v1/webhook-endpoints" \
  -H "Authorization: Bearer $VALERON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "description": "A short description.",
  "events": [
    "*"
  ],
  "url": "https://example.com"
}'
```

```js title="JavaScript"
const response = await fetch("https://api.valeron.io/v1/webhook-endpoints", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.VALERON_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "description": "A short description.",
    "events": [
      "*"
    ],
    "url": "https://example.com"
  }),
});
if (!response.ok) throw new Error(`Valeron returned ${response.status}`);
const data = await response.json();
```

```python title="Python"
import os
import requests

response = requests.post(
    "https://api.valeron.io/v1/webhook-endpoints",
    headers={"Authorization": f"Bearer {os.environ['VALERON_API_KEY']}"},
    json={
        "description": "A short description.",
        "events": [
            "*",
        ],
        "url": "https://example.com",
    },
)
response.raise_for_status()
data = response.json()
```

### Response 201

```json
{
  "created_at": "2026-12-03T14:30:00Z",
  "description": "A short description.",
  "disabled_reason": null,
  "events": [
    "*"
  ],
  "failing_since": "2026-12-03T14:30:00Z",
  "id": "whe_01JGY5XV1J",
  "is_enabled": true,
  "secret": "example",
  "updated_at": "2026-12-03T14:30:00Z",
  "url": "https://example.com"
}
```

### Response 401

```json
{
  "error": null
}
```

### Response 402

```json
{
  "error": null
}
```

### Response 403

```json
{
  "error": null
}
```

### Response 404

```json
{
  "error": null
}
```
