---
title: "Webhooks"
description: "The eight events TRUSTIVAN publishes, the signed envelope they arrive in, and the delivery guarantees a receiver must be built for."
---

A verdict a pipeline has to poll for is a verdict that arrives late or not at
all. Webhooks let a deployment gate, a chat channel or a ticket system react to
what TRUSTIVAN observed, at the moment it observed it.

## The eight events

The set is **closed**. An endpoint subscribes by naming types, and a name
nobody can subscribe to is a delivery nobody receives.

Four describe container and repository security, three describe non-human
identity. One endpoint may subscribe to kinds from either product or both. The
same signed envelope carries them all, so a receiver written for one works for
the other without changes.

### AppSec

| Event | Fires when |
|---|---|
| `scan.completed` | a scan reaches a terminal state: succeeded **or** failed |
| `verdict.recorded` | a policy decision is recorded |
| `finding.state_changed` | a scan creates, resolves or reopens a finding; a suppression expires; or a person or API key suppresses, unsuppresses or re-triages one |
| `finding.sla_breached` | findings newly pass the deadline your [SLA policy](/concepts/risk-scoring#sla-clocks) sets. Checked hourly, one delivery per check naming every finding new since the last (`count` and `findings`, at most 200, each with its `due_at`), and each finding once per breach |
| `audit.recorded` | a row is appended to the tamper-evident identity audit trail (SIEM streaming); requires the `audit_export` entitlement, the same one `GET /audit/export` requires |

### NHI Security

| Event | Fires when |
|---|---|
| `nhi.finding.state_changed` | an NHI Security posture finding opens, is triaged, is resolved or is suppressed. Carries the finding's `kind`, `policy` and `fingerprint`, so an exposed credential, an orphaned identity and an over-privileged role arrive under one subscribable name and are told apart by payload |
| `nhi.credential.expiring` | a discovered credential is close to its expiry (`standing: "expiring"`) or past it (`"expired"`), with `expires_at` (the deadline itself, so you can order a queue by it) |
| `nhi.action.denied` | the runtime mediation boundary refused (`deny`) or challenged (`challenge`) an action an agent asked to take. Refusals only: an allow is normal operation, and subscribing a pager to it would be subscribing to nothing being wrong |

Every NHI payload carries a `severity` from the same ladder as everything else
(`info`, `low`, `medium`, `high`, `critical`), a one-line `summary`, and no
credential material. An actor is named only as a kind, never as an identity.

<Note>
  NHI Security has not been deployed to production, and no connector has
  authenticated to a live provider: discovery and runtime decisions are
  verified against recorded fixtures. These three kinds are implemented and
  subscribable; they have not carried production traffic.
</Note>

`finding.state_changed` is one delivery per finding, whoever moved it: the
first scan of an image with 300 vulnerabilities sends 300, one per new finding.
`change` names what happened (`finding.created`, `finding.resolved`,
`finding.reopened`, `finding.suppression_expired`, `finding.suppressed`, …) and
`actor` says who: `scan`, `system` for an expiry, or `user` / `apikey`.

`audit.recorded` is the push half of the [audit trail](/concepts/audit-trail):
`GET /audit/export` is a customer *pulling* the trail on demand; this is
TRUSTIVAN *pushing* it, near real time, to a SIEM or log pipeline the customer
configured. See that page for exactly what is, and is not, on the payload.

`scan.completed` fires for failures too, on purpose. A receiver that only heard
about successes could not tell "clean" from "never ran", which is the
difference between a green build and an unmonitored one.

Two silences are also deliberate. A **retried** verdict request returns the
existing decision and announces nothing: one decision happened once, so it is
reported once. A **retryable** scan failure returns the scan to `queued` and
stays silent, because announcing `scan.completed` while the scan waits for its
next attempt would be a lie.

## Register an endpoint

Requires `webhooks:manage`, which is **not grantable to an API key**. An
endpoint is a destination every future event is copied to, so a credential that
could add one could arrange for a tenant's security findings to be streamed
somewhere the tenant never chose: exfiltration with an audit trail that reads
like configuration. This is a human action, from the dashboard or a session.

```bash
curl -s -X POST https://app.trustivan.com/api/v1/webhooks \
  -H 'Content-Type: application/json' \
  -b cookies.txt \
  -H "X-CSRF-Token: $(grep trustivan_csrf cookies.txt | awk '{print $7}')" \
  -d '{
        "name": "deployment-gate",
        "url": "https://hooks.example.com/trustivan",
        "events": ["verdict.recorded", "scan.completed"]
      }'
```

The response carries `secret`: a `whsec_…` value, returned **once**, by create
and by rotate. There is no read path, not for an admin and not for support: a
secret that can be fetched is one that ends up in a screenshot.

Subscribe to what you will act on. An endpoint that received everything would
be one whose owner cannot reason about what it will be sent.

`webhooks:read` **is** grantable, because a machine checking whether delivery
is working is a legitimate thing to do.

## The envelope

```json
{
  "version": "2026-08-20",
  "id": "d29b1f2e-…",
  "event": "verdict.recorded",
  "occurred_at": "2026-08-20T05:39:18Z",
  "organization_id": "…",
  "data": {
    "scan_id": "…",
    "result": "fail",
    "blocking": true,
    "summary": "…",
    "rules": []
  }
}
```

The envelope is identical across event types, so a receiver can log,
deduplicate and route a delivery without knowing anything about the event
inside it.

**The contract is versioned by date**, and payload types are written by hand
rather than serialised from database models. The duplication is the feature: a
model is an internal shape that changes whenever the schema does, while a
payload is a published contract customers write code against. Serialising a
model straight to the wire would make every migration a silent breaking change
to somebody else's pipeline. Fields may be added within a version; none is ever
removed or repurposed.

`blocking` is precomputed rather than left to the receiver, for the same reason
it is precomputed in the verdict response: a gate should not reimplement
TRUSTIVAN's opinion about which results stop a deployment, because then TRUSTIVAN
cannot change that opinion.

### What never travels

No API keys, no signing secrets, no session tokens, no passwords, and no
scanner-engine structures, only TRUSTIVAN domain contracts. And
`finding.state_changed`, `audit.recorded` and `nhi.finding.state_changed` all
name an actor **kind** (`user`, `apikey`/`api_key`, `scan`, `system`,
`workload`, `scim`), never an identity. The audit trail records who acted and is read inside the tenant; a
payload goes to a destination the customer chose, and "alice@example.com
suppressed this" is not something to hand to an arbitrary URL.
`audit.recorded` additionally withholds the row's `before`/`after`/`detail`
fields. See [Audit trail](/concepts/audit-trail) for the full redaction
rationale.

## Delivery guarantees

**Published from a transactional outbox.** An event becomes a row before it
becomes a request, written in the same transaction as the thing it describes.
The delivery row and the fact it describes commit together or not at all, so a
crash between committing a verdict and sending its webhook cannot lose the
event, a failed POST is not the only record of what happened, and a receiver
that takes thirty seconds to answer does not hold a database transaction open
for thirty seconds.

The three NHI kinds are reported to this backend over an authenticated endpoint
rather than produced inside a transaction here, so for them the guarantee is one
step narrower: the publisher's own `event_id` makes a retry fan out exactly once,
and the delivery row is still committed before any request is made.

**At-least-once.** A uniqueness constraint collapses a retried publish and two
racing workers onto one row, but a delivery can genuinely be *sent* twice when
a response is lost.

> **Receivers must be idempotent.** Deduplicate on `X-TrustIvan-Delivery`, which
> is the same value as the envelope's `id`.

**Exponential backoff**, from 30 seconds to a 2-hour cap, over about a day and
six attempts before a delivery is terminally `failed`. Fixed intervals turn a
downed endpoint into a steady stream of pointless requests at a receiver that
is already struggling, and an endpoint unreachable for hours is not rescued by
attempt two hundred.

**Ten seconds per attempt**, with the response body read up to 8 KB. A slow
receiver must not be able to hold a delivery worker open: that is how one
customer's broken endpoint becomes every customer's backlog. Acknowledge as
soon as you have verified and durably recorded the delivery; do the work
afterwards.

**An endpoint failing 20 times consecutively is disabled**, with the reason
recorded. Re-enabling clears the streak, so an operator who has fixed their
receiver is not disabled again by the failures that preceded the fix.

A terminal delivery is immutable. It is the evidence behind "we did notify
you".

## Destination restrictions

A webhook is a request whose destination the customer chooses, made from inside
TRUSTIVAN's network: the definition of server-side request forgery, with the
destination attacker-controlled by design.

Loopback, private (RFC1918), carrier-grade NAT, link-local (**including the
cloud instance metadata service**), unique-local IPv6, multicast, reserved and
documentation ranges are refused, as is the IPv4-mapped IPv6 spelling of each.
The URL is checked when the endpoint is configured, but that is the shallow
half, present to give an actionable message early. The real control runs at
connection time on **every** resolved address, after DNS and before `connect`,
so DNS rebinding does not work and a name with several A records cannot smuggle
one bad address past a check that only looked at the first.

**Redirects are not followed**, and proxying is disabled. A public host that
answers `302` to the metadata service is the classic bypass; a webhook has no
legitimate reason to be redirected, so the class is removed rather than
defended.

For local development, `WEBHOOK_ALLOW_PRIVATE_DESTINATIONS=true` lifts the
loopback and private-range refusal and logs a loud warning. Configuration
**refuses to start** with it set outside development, and even with it set the
metadata range stays blocked.

## Rotating the signing secret

```bash
curl -s -X POST "https://app.trustivan.com/api/v1/webhooks/$ENDPOINT_ID/rotate-secret" \
  -b cookies.txt \
  -H "X-CSRF-Token: $(grep trustivan_csrf cookies.txt | awk '{print $7}')"
```

The previous secret keeps working for a **24-hour overlap**, during which
deliveries are signed with both, space-separated in the header. A receiver
accepts a delivery if **any** signature verifies. Without the overlap, rotating
would drop every delivery between the rotation and the receiver being
reconfigured, which makes rotation an outage, and an outage is a thing people
avoid doing.

## Seeing what happened

```bash
curl -s "https://app.trustivan.com/api/v1/webhooks/deliveries?endpoint_id=$ENDPOINT_ID&limit=20" \
  -H "Authorization: Bearer $TRUSTIVAN_KEY" \
  | jq '.deliveries[] | {event, status, attempts, response_status, error, delivered_at}'
```

Failure messages are sanitised: a raw transport error names the resolved IP,
the port and sometimes the proxy, and these records are shown in the dashboard
and read by support. The one exception is a blocked address, where the guard's
own message is relayed in full. There, the URL *is* the problem.

## Bounds

- At most **20 endpoints** per organisation. Each event fans out to every
  subscriber, so this is the multiplier on delivery work a single scan can
  create.
- A bulk operation publishes **one event per finding**. Five hundred suppressed
  findings genuinely are five hundred state changes, and collapsing them would
  leave a receiver unable to tell which findings moved. Bounded on both sides:
  500 findings × 20 endpoints.

## See also

- [Verify a webhook signature](/how-to/verify-webhooks): a working
  receiver in Python and Node.
- [Troubleshooting webhooks](/troubleshooting/webhooks): deliveries that
  do not arrive, and endpoints that get disabled.
- [Integrations overview](/integrations/overview): the other surface,
  and what does not exist.
