# Webhooks API

> Webhook endpoints, test events and deliveries. Every route, its parameters and fields.

Webhook endpoints, test events and deliveries. 11 routes; send a bearer token with each (see [Authentication](/api/authentication.md)).

| Route | What it does |
| --- | --- |
| `GET /v1/webhook-event-types` | Event types an endpoint can subscribe to |
| `GET /v1/webhook-endpoints` | Webhook endpoints (admins) |
| `POST /v1/webhook-endpoints` | Create a webhook endpoint (admins) |
| `GET /v1/webhook-endpoints/{id}` | A webhook endpoint (admins) |
| `PATCH /v1/webhook-endpoints/{id}` | Change, resume or disable a webhook endpoint (admins) |
| `DELETE /v1/webhook-endpoints/{id}` | Delete a webhook endpoint (admins) |
| `POST /v1/webhook-endpoints/{id}/rotate-secret` | Rotate the signing secret (admins) |
| `POST /v1/webhook-endpoints/{id}/test` | Send a test event (admins) |
| `GET /v1/webhook-endpoints/{id}/deliveries` | Delivery log of an endpoint (admins) |
| `POST /v1/webhook-endpoints/{id}/deliveries/{delivery_id}/redeliver` | Redeliver one dead event (admins) |
| `POST /v1/webhook-endpoints/{id}/redeliver` | Redeliver the dead events of an endpoint (admins) |

## Event types an endpoint can subscribe to

`GET https://staging-api.naruskacrm.com/v1/webhook-event-types`

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `data` | array of string | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Webhook endpoints (admins)

`GET https://staging-api.naruskacrm.com/v1/webhook-endpoints`

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `data` | array of object | yes |  |
| `data[].id` | string (uuid) | yes |  |
| `data[].url` | string | yes |  |
| `data[].description` | string or null | yes |  |
| `data[].event_types` | array of string | yes |  |
| `data[].secret_prefix` | string | yes |  |
| `data[].previous_secret_expires_at` | string (date-time) or null | yes |  |
| `data[].status` | `active`, `paused`, `disabled` | yes |  |
| `data[].paused_reason` | string or null | yes |  |
| `data[].consecutive_failures` | integer | yes |  |
| `data[].failing_since` | string (date-time) or null | yes |  |
| `data[].last_success_at` | string (date-time) or null | yes |  |
| `data[].last_failure_at` | string (date-time) or null | yes |  |
| `data[].created_at` | string (date-time) | yes |  |
| `data[].updated_at` | string (date-time) | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Create a webhook endpoint (admins)

`POST https://staging-api.naruskacrm.com/v1/webhook-endpoints`

The signing secret (whsec_…) is in this response only; a replay with the same Idempotency-Key returns secret: null. Plans cap the number of active endpoints. The id is always generated; a body with an id is refused.

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `url` | string | yes | 1–2000 characters |
| `description` | string or null |  | at most 500 characters |
| `event_types` | array of string | yes | at most 50 items |
| `status` | `active`, `disabled` |  | default `"active"` |

### Response 201

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `id` | string (uuid) | yes |  |
| `url` | string | yes |  |
| `description` | string or null | yes |  |
| `event_types` | array of string | yes |  |
| `secret_prefix` | string | yes |  |
| `previous_secret_expires_at` | string (date-time) or null | yes |  |
| `status` | `active`, `paused`, `disabled` | yes |  |
| `paused_reason` | string or null | yes |  |
| `consecutive_failures` | integer | yes |  |
| `failing_since` | string (date-time) or null | yes |  |
| `last_success_at` | string (date-time) or null | yes |  |
| `last_failure_at` | string (date-time) or null | yes |  |
| `created_at` | string (date-time) | yes |  |
| `updated_at` | string (date-time) | yes |  |
| `secret` | string or null | yes |  |
| `detail` | string |  |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## A webhook endpoint (admins)

`GET https://staging-api.naruskacrm.com/v1/webhook-endpoints/{id}`

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `id` | string (uuid) | yes |  |
| `url` | string | yes |  |
| `description` | string or null | yes |  |
| `event_types` | array of string | yes |  |
| `secret_prefix` | string | yes |  |
| `previous_secret_expires_at` | string (date-time) or null | yes |  |
| `status` | `active`, `paused`, `disabled` | yes |  |
| `paused_reason` | string or null | yes |  |
| `consecutive_failures` | integer | yes |  |
| `failing_since` | string (date-time) or null | yes |  |
| `last_success_at` | string (date-time) or null | yes |  |
| `last_failure_at` | string (date-time) or null | yes |  |
| `created_at` | string (date-time) | yes |  |
| `updated_at` | string (date-time) | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Change, resume or disable a webhook endpoint (admins)

`PATCH https://staging-api.naruskacrm.com/v1/webhook-endpoints/{id}`

status: active resumes a paused or disabled endpoint: the failure counters reset and the plan cap is checked. A signed-in user cannot pause an endpoint; only the delivery service does.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `url` | string |  | 1–2000 characters |
| `description` | string or null |  | at most 500 characters |
| `event_types` | array of string |  | at most 50 items |
| `status` | `active`, `disabled` |  |  |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `id` | string (uuid) | yes |  |
| `url` | string | yes |  |
| `description` | string or null | yes |  |
| `event_types` | array of string | yes |  |
| `secret_prefix` | string | yes |  |
| `previous_secret_expires_at` | string (date-time) or null | yes |  |
| `status` | `active`, `paused`, `disabled` | yes |  |
| `paused_reason` | string or null | yes |  |
| `consecutive_failures` | integer | yes |  |
| `failing_since` | string (date-time) or null | yes |  |
| `last_success_at` | string (date-time) or null | yes |  |
| `last_failure_at` | string (date-time) or null | yes |  |
| `created_at` | string (date-time) | yes |  |
| `updated_at` | string (date-time) | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Delete a webhook endpoint (admins)

`DELETE https://staging-api.naruskacrm.com/v1/webhook-endpoints/{id}`

Soft delete: nothing more is queued or delivered to it; its delivery log is kept 30 days.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 204

Done.
No body.

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Rotate the signing secret (admins)

`POST https://staging-api.naruskacrm.com/v1/webhook-endpoints/{id}/rotate-secret`

Returns a new secret (shown once). For 24 hours deliveries are signed with both the new and the previous secret, so receivers can switch without downtime. Two rotations within 24 hours leave only the latest previous secret valid: the older one stops working at the second rotation. A rotation cannot be undone.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `id` | string (uuid) | yes |  |
| `url` | string | yes |  |
| `description` | string or null | yes |  |
| `event_types` | array of string | yes |  |
| `secret_prefix` | string | yes |  |
| `previous_secret_expires_at` | string (date-time) or null | yes |  |
| `status` | `active`, `paused`, `disabled` | yes |  |
| `paused_reason` | string or null | yes |  |
| `consecutive_failures` | integer | yes |  |
| `failing_since` | string (date-time) or null | yes |  |
| `last_success_at` | string (date-time) or null | yes |  |
| `last_failure_at` | string (date-time) or null | yes |  |
| `created_at` | string (date-time) | yes |  |
| `updated_at` | string (date-time) | yes |  |
| `secret` | string or null | yes |  |
| `detail` | string |  |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Send a test event (admins)

`POST https://staging-api.naruskacrm.com/v1/webhook-endpoints/{id}/test`

Queues a signed ping event for an active endpoint. A test is one attempt: no retries, not counted toward pausing, not redeliverable. It counts toward the webhooks.deliveries quota (at the hard stop, 105 %, it returns 429 quota_exceeded and queues nothing) and appears in the delivery log.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `event_id` | string | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Delivery log of an endpoint (admins)

`GET https://staging-api.naruskacrm.com/v1/webhook-endpoints/{id}/deliveries`

Every attempt, retries included, newest first, kept 30 days.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |
| `limit` | query | integer |  | 1–200, default `50` |
| `cursor` | query | string (uuid) |  |  |
| `status` | query | `succeeded`, `failed`, `dead` |  |  |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `data` | array of object | yes |  |
| `data[].id` | string (uuid) | yes |  |
| `data[].endpoint_id` | string (uuid) | yes |  |
| `data[].event_id` | string | yes |  |
| `data[].event_type` | string | yes |  |
| `data[].attempt` | integer | yes |  |
| `data[].status` | `succeeded`, `failed`, `dead` | yes |  |
| `data[].response_status` | integer or null | yes |  |
| `data[].response_excerpt` | string or null | yes |  |
| `data[].duration_ms` | integer or null | yes |  |
| `data[].error_code` | string or null | yes |  |
| `data[].next_attempt_at` | string (date-time) or null | yes |  |
| `data[].created_at` | string (date-time) | yes |  |
| `data[].redeliverable` | boolean | yes |  |
| `next_cursor` | string or null | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Redeliver one dead event (admins)

`POST https://staging-api.naruskacrm.com/v1/webhook-endpoints/{id}/deliveries/{delivery_id}/redeliver`

Queues the dead event again (same event id) for an active endpoint, within 30 days. Checks the webhooks.deliveries quota first; the new attempts are metered. queued is 0 when the event was already redelivered.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |
| `delivery_id` | path | string (uuid) | yes |  |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `queued` | integer | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Redeliver the dead events of an endpoint (admins)

`POST https://staging-api.naruskacrm.com/v1/webhook-endpoints/{id}/redeliver`

Queues every dead event of the endpoint still inside the 30-day window, optionally only those that died between since and until. Checks the webhooks.deliveries quota first; each resulting attempt is metered.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `since` | string (date-time) |  |  |
| `until` | string (date-time) |  |  |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `queued` | integer | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

