# Webhooks

A webhook sends selected Phantom events to a URL as they happen: a new
finding into your tracker, a finished scan into a pipeline, a report
status into chat. Set them up in **Settings › Integrations**.

## Events

| Event | Sent when |
|---|---|
| `finding.created` | a finding is recorded |
| `finding.updated` | a finding's state, severity or details change |
| `finding.deleted` | a finding is deleted |
| `scan.completed` | a scan finishes |
| `report.updated` | a report changes (status, sections, approval) |
| `vault.scope_change` | a vault's scope changes |
| `vault.testing_suspended` | active testing is suspended in a vault |
| `engagement.updated` | a vault's engagement rules change |
| `bounty.updated` | a bounty program is refreshed |

A webhook subscribes to some of them, from every vault or from the vaults
you choose. Live interface events (traffic, scan progress, logs) are
never sent.

## Payload

```json
{
  "id": "0f8c…",
  "type": "finding.created",
  "created_at": "2026-12-11T10:00:00+00:00",
  "vault_id": 3,
  "data": { "id": 41, "title": "Open redirect on /login", "severity": "medium" }
}
```

Credentials in `data` are masked, as in what agents receive. `id` is the
delivery id, also sent as the `Phantom-Delivery` header; the event name
is in `Phantom-Event`.

## Chat formats

A webhook can post to a chat instead: choose **Slack**, **Microsoft
Teams** or **Discord** as its format and paste the channel's incoming
webhook URL. Each event then arrives as one line, for example
`Phantom · finding.created in vault 3: Open redirect on /login (severity
medium)`, with credentials masked. Slack and Teams receive
`{"text": …}`, Discord `{"content": …}`. Chat services ignore the
signature headers; the delivery log, retries and **Send again** work the
same.

## Email

Choose **Email through my SMTP server** to receive events by email:

- the URL is `smtps://host:465` (TLS from the start) or
  `smtp://host:587`, where STARTTLS is required unless the server is on
  this machine or your network;
- up to ten recipients, and the SMTP user and password (the password is
  encrypted with the configuration key);
- each event is one message: the subject is its line, the body adds the
  masked payload as JSON, with `X-Phantom-Event` and `X-Phantom-Delivery`
  headers.

The server's address is checked like any destination, and deliveries
are retried and logged like the other formats.

## Splunk

Choose **Splunk HTTP Event Collector**, set the URL to the collector's
event endpoint (`https://splunk.example.com:8088/services/collector/event`)
and paste the HEC token; it is encrypted and sent as
`Authorization: Splunk <token>`. Each event arrives with
`sourcetype` `phantom:event`, `source` `phantom`, the event's time, and
the masked payload as `event`. The signature headers are sent as well.

## Verifying a delivery

Each webhook has a signing secret (`whsec_…`), shown once when you create
it or choose **New secret**. Every request carries:

```text
Phantom-Signature: t=1733911200,v1=5f2b…
```

`v1` is the hex HMAC-SHA256, keyed with the secret, of the timestamp, a
dot and the exact request body. A receiver should:

1. compute the HMAC over `"<t>." + body` and compare it with `v1` in
   constant time;
2. refuse a `t` more than five minutes from its own clock;
3. ignore a `Phantom-Delivery` id it has already processed.

In Python:

```python
import hashlib, hmac, time

def valid(secret: str, header: str, body: bytes) -> bool:
    parts = dict(item.split('=', 1) for item in header.split(','))
    if abs(time.time() - int(parts['t'])) > 300:
        return False
    expected = hmac.new(secret.encode(), f"{parts['t']}.".encode() + body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, parts['v1'])
```

## Delivery

A delivery counts as received on any 2xx answer within 10 seconds.
Otherwise it is tried again after 1 minute, 5 minutes, 30 minutes,
2 hours and 6 hours, then marked failed. Redirects are not followed.

The delivery log of each webhook shows its newest 200 deliveries with
their status, attempts, the answer and the next retry. **Send again**
queues one at once with the same delivery id, so a receiver that already
handled it can recognise it. **Ping** sends a signed `ping` event to test
the receiver.

## Where a webhook may point

- Other machines only over **https**.
- A receiver on this machine or your local network (`localhost`, a
  loopback or private address) only after you confirm that host and port.
- Cloud metadata addresses, other non-routable ranges and Phantom's own
  API and proxy ports are always refused.

## Who manages webhooks

Only you, in the interface. Agents cannot list, create or change
webhooks over MCP or REST, since a webhook sends workspace events off the
machine.
