---
title: "NHI webhooks"
description: "Signed NHI Security events at your HTTPS endpoint: findings opened and resolved, lifecycle changes and expiring credentials, retried and logged."
keywords: ["NHI webhooks", "outbound events", "SOC automation", "HMAC-SHA256", "webhook signature", "finding.opened", "identity.lifecycle_changed", "credential.expiring"]
---

A webhook endpoint receives a JSON `POST` from NHI Security when something changes in your estate. Use it to open a ticket, page someone or feed a SIEM without polling the API.

## Add an endpoint

In the console, open **Settings** and use the **Webhooks** panel. Adding, deleting and testing an endpoint needs `organization:update`; seeing endpoints and their delivery log needs `organization:read`. An organization can have up to 10 endpoints.

The same through the API:

```bash
curl -X POST https://nhi.example.com/api/v1/webhooks \
  -H 'Content-Type: application/json' -H "X-CSRF-Token: $CSRF" -b cookies.txt \
  -d '{"url": "https://hooks.example.com/nhi", "description": "SOC"}'
```

The response carries the endpoint and its signing secret (`whsec_…`). **The secret is returned once and never again**; copy it into your receiver's configuration. You can pass your own `secret` (32 to 256 characters) instead of having one generated. It is stored encrypted with the deployment's credential encryption key and is not readable through any API.

The URL must use `https`, port 443, 6443 or 8443, carry no user name, password or token, and name a public host. NHI Security refuses private, loopback, link-local and metadata addresses when you add the endpoint, and again on every delivery against every address the host name resolves to, so a DNS record pointing at an internal address is refused at send time. Redirects are not followed.

| Route | Permission | Does |
|---|---|---|
| `GET /api/v1/webhooks` | `organization:read` | Lists endpoints. Never includes the secret |
| `POST /api/v1/webhooks` | `organization:update` | Adds one. Body: `url`, optional `description`, optional `secret` |
| `DELETE /api/v1/webhooks/{id}` | `organization:update` | Deletes it and its delivery log |
| `POST /api/v1/webhooks/{id}/test` | `organization:update` | Sends a signed `webhook.test` event now and returns the delivery |
| `GET /api/v1/webhooks/{id}/deliveries` | `organization:read` | The 50 most recent deliveries |

Adding, deleting and testing are recorded in the audit trail as `webhook.created`, `webhook.deleted` and `webhook.test_sent`.

## Events

Every delivery body has the same envelope:

```json
{
  "id": "6f1c2b9e-…",
  "type": "finding.opened",
  "occurredAt": "2026-11-18T09:12:44.000Z",
  "data": { }
}
```

`id` is the event's own identifier and is the same for every endpoint that receives it, so a receiver can drop duplicates on it.

| `type` | Sent when | `data` |
|---|---|---|
| `finding.opened` | A policy evaluation raises a new finding, or reopens a resolved one | `findingId`, `policy`, `kind`, `severity`, `summary`, `status`, `previousStatus` (null when new), `subject` (`kind`, `id`), `identityId` |
| `finding.resolved` | An evaluation, or a reassessment after a change such as an owner being assigned, finds the policy no longer matches | the same fields, with `status: "resolved"` |
| `identity.lifecycle_changed` | The [lifecycle sweep](/nhi-security/concepts#lifecycle) sets or clears `stale` or `orphaned` | `identityId`, `displayName`, `from`, `to`, `basis` |
| `credential.expiring` | A credential's reported expiry comes within 14 days. Once per expiry date | `credentialId`, `identityId`, `displayName`, `type`, `expiresAt`, `warningDays` |
| `webhook.test` | Someone pressed **Send test** | `message` |

An event is queued in the same database transaction as the change it reports, so a change that rolls back sends nothing and a committed one is not lost if the process stops before sending. No event carries credential material, evidence or raw provider output.

## Verify a delivery

Each request carries four headers:

```text
X-Webhook-Delivery:  2a4e…          (this delivery's id)
X-Webhook-Event:     finding.opened
X-Webhook-Timestamp: 1795511564     (Unix seconds, when it was sent)
X-Webhook-Signature: v1=9f86d081…
```

The signature is `HMAC-SHA256`, keyed with the endpoint's secret, over exactly:

```text
v1:<delivery id>:<timestamp>:<raw body>
```

This is the scheme the AppSec webhooks use, so the verifier in [Verify a webhook signature](/how-to/verify-webhooks) works unchanged once it reads the `X-Webhook-…` header names. In Node:

```js
import { createHmac, timingSafeEqual } from 'node:crypto';

export function verify(secret, headers, rawBody, now = Date.now() / 1000) {
  const ts = Number(headers['x-webhook-timestamp']);
  const id = headers['x-webhook-delivery'] ?? '';
  if (!Number.isFinite(ts) || Math.abs(now - ts) > 300 || id === '') return false;
  const expected =
    'v1=' + createHmac('sha256', secret).update(`v1:${id}:${ts}:`).update(rawBody).digest('hex');
  const given = String(headers['x-webhook-signature'] ?? '');
  return given.length === expected.length && timingSafeEqual(Buffer.from(given), Buffer.from(expected));
}
```

Verify against the raw bytes before parsing the JSON, and reject a timestamp more than five minutes from your clock. A retry is signed again when it is sent, so its timestamp is fresh.

## Delivery and retries

Any `2xx` answer within 10 seconds counts as delivered. Anything else, including a timeout, a refused address or a redirect, is a failed attempt. Failed deliveries are retried after 30 seconds, then with the wait doubling up to two hours, for 12 attempts in all (about eight hours); after that the delivery is marked `failed`. The delivery log on **Settings → Webhooks** shows each delivery's event, status, attempts and the last answer (HTTP status or error).

Deliveries are sent by an in-process worker every 30 seconds, which runs only when `DISCOVERY_SCHEDULER_ENABLED` is on (the default when `APP_ENV=production`; see [Configuration](/nhi-security/configuration)). With it off, events still queue and show as `pending`; **Send test** always sends at once.

## Limits

- Every endpoint receives every event type. Filter on `type` in your receiver.
- A secret cannot be rotated in place. Add a second endpoint with a new secret, move your receiver over, then delete the old one.
- Rotating the deployment's credential encryption key does not re-encrypt webhook secrets. Keep the old key listed in `CREDENTIAL_ENCRYPTION_RETIRED_KEYS` until every endpoint has been recreated.
- Deliveries are not ordered: a retry can arrive after a later event. Use `occurredAt` to order them.
