# Outbound webhooks

Source: https://pinprompt.veren-technology.com/docs/reference/webhooks

pinprompt POSTs signed JSON to your own endpoints when items change: a dashboard, a chat bot, another agent system. Like every integration it follows the event log: it never sits inside a request, and pausing it changes nothing else.

## Set it up

You need the **owner** role on the project (webhooks send project data to a URL you choose). Developers can see the endpoints and the delivery log.

1. **Project → Settings → Integrations → Webhooks → Add endpoint.**
2. Enter the URL, an optional description, and the events (or **All item events**, which also covers event types added later). A project can have up to 10 endpoints, each with its own events and secret.
3. pinprompt shows the **signing secret once** (`whsec_…`). Put it in your receiver. Lost it? **Rotate** (key icon) makes a new one.
4. **Send test** posts a `webhook.test` event right away and shows the status code and latency.

In production the URL must be `https` and must not point at a private or internal address (see "Outbound safety"). Outside production anything http(s) works, so you can point it at a local receiver.

## What is sent

`POST <your URL>` with `content-type: application/json` and `user-agent: pinprompt-webhooks/1`:

```json
{
  "id": "evt_k2v9…",
  "type": "item.status_changed",
  "createdAt": "2026-10-16T09:12:03.120Z",
  "project": { "id": "prj_…", "key": "FB", "name": "Halden Coffee", "slug": "halden-coffee", "url": "https://pinprompt.agency.dev/p/halden-coffee" },
  "item": {
    "id": "itm_…", "key": "FB-1191", "title": "Card titles overlap on tablet", "kind": "bug",
    "status": "agent_ready", "statusLabel": "Agent ready", "priority": "P2",
    "pageUrl": "https://staging.halden.coffee/collections", "pagePath": "/collections",
    "url": "https://pinprompt.agency.dev/p/halden-coffee/FB-1191",
    "createdAt": "…", "updatedAt": "…", "closedAt": null
  },
  "data": { "key": "FB-1191", "from": "triage", "to": "agent_ready", "actor": { "type": "user", "name": "Mia Hart" } }
}
```

- `id` is the event id. It is also the `webhook-id` header and stays the same on every retry: dedupe on it.
- `item` is the item **as it is when the delivery is sent** (a late retry shows the newest status); `data` is what the event recorded.
- `data` is the event's own payload, filtered: keys that look like secrets, tokens, passwords, emails, integration config, capture or anchor data are dropped at any depth, long strings are clipped to 1,000 characters. People appear by name only (`actor`), never by email. Nothing goes out that a developer on the project couldn't see, and never a secret.

### Events

Every `item.*` event in `packages/spec` (`EVENT_TYPES`): `item.created`, `item.commented`, `item.voted`, `item.status_changed`, `item.assigned`, `item.priority_changed`, `item.kind_changed`, `item.labels_changed`, `item.spec_revised`, `item.question_asked`, `item.question_answered`, `item.question_dismissed`, `item.merged`, `item.claimed`, `item.run_attached`, `item.run_updated`, `item.verified`, `item.verification_failed`, `item.external_linked`, and any added later. `*` (**All item events** in settings) means all of these, including ones added later. The two bulk events below (`WEBHOOK_BULK_EVENTS`) are opt-in: `*` doesn't include them; pick them by name, alone or next to `*`. "Send test" sends `webhook.test` (no `item`).

`item.deleted` is a tombstone: the item is gone, so the body has **no `item`**, and `data` is only `{ key, status, files, links?, by?, actor }` (`links`: the issue and PR links it had, `by: "reporter"` when the reporter took it back). Delete or archive your copy by `data.key`. `item.evidence_removed` (`{ key, days, files }`, actor `system`) says the workspace retention removed the item's screenshots, recordings and logs.

An item event that is part of a bulk change carries `data.bulkId`; one written by undoing a bulk change carries `data.undoOf` (the bulk id it undid). The body is otherwise the one above.

### Bulk changes: `items.bulk_changed` and `items.bulk_undone`

A bulk change in the inbox (two or more items: move, assign, priority, kind, labels, route, merge) is **one delivery** of type `items.bulk_changed` per project, sent after every item in it has changed, to endpoints that picked `items.bulk_changed`. Undoing it is one `items.bulk_undone`, to endpoints that picked that.

```json
{
  "id": "evt_9qd2…",
  "type": "items.bulk_changed",
  "createdAt": "2026-10-16T09:14:40.002Z",
  "project": { "id": "prj_…", "key": "FB", "name": "Halden Coffee", "slug": "halden-coffee", "url": "…" },
  "data": {
    "bulkId": "blk_7f3k…", "action": "status", "summary": "moved to With people",
    "count": 14, "failed": 0, "keys": ["FB-1191", "FB-1192", "…"],
    "actor": { "type": "user", "name": "Mia Hart" }
  },
  "items": [
    {
      "id": "itm_…", "key": "FB-1191", "title": "…", "status": "with_people", "…": "the same item object as above",
      "events": [
        { "id": "evt_…", "type": "item.status_changed", "createdAt": "…",
          "data": { "key": "FB-1191", "from": "triage", "to": "with_people", "bulkId": "blk_7f3k…", "actor": { "type": "user", "name": "Mia Hart" } } }
      ]
    }
  ]
}
```

- `id` is the bulk change's own event id (the `webhook-id`); it is signed, retried and deduped exactly like any delivery.
- `items` lists every item that changed, in the order they changed (up to 500, the bulk limit, plus the item merged into for a merge), each with the item events it wrote (a route writes a status change and an assignment; merging into an item writes `item.spec_revised` on it).
- **Each entry is the per-item body, unpacked:** `{ ...event, project, item }` for each of an item's `events` is exactly the `item.*` body that event would have been sent as on its own. A receiver that already handles item events can do `for (const i of body.items) for (const e of i.events) handle({ ...e, project: body.project, item: i })`.
- `data.keys` lists every key, `data.count` how many changed, `data.failed` how many in this project couldn't be changed (they are not in `items`). Failures in other projects are in their own project's delivery.
- If a bulk change (or its undo) is cut off before it finishes (the server stopped half-way), a housekeeping job sends the delivery about 5 minutes later for the items that did change: `data.summary` reads "changed N items" and `data.failed` is 0. A change cut off like that can't be undone.
- `items.bulk_undone` has the same shape: `data.summary` is what was undone, `items` are the items that went back, with the item events the undo wrote (each with `undoOf`). Items that had changed since aren't put back and aren't listed.

**Who gets what.** An endpoint that picked `items.bulk_changed` by name (with or without `*`) gets the one bulk delivery and **not** the bulk change's item events one by one. Every other endpoint, `*` included, still gets each item event it subscribes to, tagged with `data.bulkId`. The same goes for `items.bulk_undone` and item events tagged `undoOf`.

Why this way: a bulk change is one decision by one person, and many receivers (a chat bot, an ops feed) would rather hear it once. But an endpoint that mirrors item state (on `*` or on, say, `item.status_changed`) would be left wrong if hundreds of item events turned into a type it ignores, and nothing it subscribed to would tell it why. So one delivery is opt-in: per-item deliveries stop only for endpoints that asked for the bulk event, and the bulk body carries the full per-item bodies, so switching loses nothing.

**Size.** A delivery lists up to 500 changed items plus, for a merge, the item merged into. Expect about 0.5 MB for 500 items routed and assigned, and up to about 1 MB for label changes or comments (strings are clipped to 1,000 characters, comment bodies to 280). Raise your receiver's body limit if it is lower (Express's `express.json()` defaults to 100 kB); a `413` is retried like any other failure and then fails.

## Verifying signatures

Deliveries follow [Standard Webhooks](https://www.standardwebhooks.com/), so any of its libraries verifies them. By hand:

```
webhook-id:        evt_k2v9…               (message id, stable across retries)
webhook-timestamp: 1760605923             (unix seconds of this attempt)
webhook-signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4=
```

```
signed   = webhook-id + "." + webhook-timestamp + "." + raw request body
key      = base64-decode(secret without the "whsec_" prefix)
expected = "v1," + base64(HMAC-SHA256(key, signed))
```

Accept when any space-separated entry in `webhook-signature` equals `expected` (constant-time compare) and the timestamp is within 5 minutes of now (replay protection). Verify against the raw body bytes, before parsing JSON.

Node:

```ts
import crypto from "node:crypto";
function verify(secret: string, h: Headers, body: string): boolean {
  const id = h.get("webhook-id"), ts = h.get("webhook-timestamp"), sigs = h.get("webhook-signature");
  if (!id || !ts || !sigs || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
  const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
  const want = Buffer.from("v1," + crypto.createHmac("sha256", key).update(`${id}.${ts}.${body}`).digest("base64"));
  return sigs.split(" ").some((s) => s.length === want.length && crypto.timingSafeEqual(Buffer.from(s), want));
}
```

Test vector (from the Standard Webhooks spec, checked in `packages/core/test/webhooks.test.ts`): secret `whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw`, id `msg_p5jXN8AQM9LWM0D4loKWxJek`, timestamp `1614265330`, body `{"test": 2432232314}` → `v1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE=`.

### Rotating a secret

**Rotate** makes a new secret and shows it once. For 24 hours every delivery carries **two** signatures (new and old), so you can deploy the new secret to your receiver without dropping anything; then only the new one signs. **Revoke old now** skips the overlap (use it when a secret leaked).

## Delivery, retries and the log

- One background delivery per event covers every endpoint subscribed to it (a bulk change is one event: its summary). A `2xx` answer is success.
- Any other status, a timeout (10 s) or a network error is retried with backoff (30 s, 1 m, 2 m, 4 m, 8 m: six attempts in about 15 minutes). An endpoint that already accepted the event is **not** sent it again when the retry is for another endpoint.
- A `3xx` is a failure and is **not** followed (update the URL instead). It is not retried, nor is a refused destination.
- The card shows each endpoint's last result, and **Recent deliveries** lists every attempt with its status code, latency and error. Failed events can be retried from the card (**Retry now**).
- Pause an endpoint with its switch; events while it is paused are not replayed. Removing an endpoint deletes its secret and its log.
- The log is kept 30 days.

## Outbound safety

All integrations (GitHub, Slack, webhooks) go through one guarded fetch (`packages/core/src/integrations/http.ts`):

- http(s) only, no credentials in URLs;
- the host name is resolved **once**; in production every resolved address must be public (no loopback, private, link-local, CGNAT, metadata, multicast, mapped/NAT64/6to4/Teredo IPv6). The connection then goes to that checked address, with the original Host header and TLS name, so a DNS answer that changes between the check and the connect (rebinding) is never used;
- redirects are never followed; responses are capped at 5 MB and time out (10 s).

`PINPROMPT_OUTBOUND_ALLOW_PRIVATE=1` lets a self-hosted pinprompt reach private addresses in production (an internal GitHub Enterprise or receiver). Endpoint URLs must still be `https` in production.

## Local testing

Point an endpoint at any local receiver (outside production, private addresses and http are allowed):

```bash
node -e 'require("http").createServer((q,s)=>{let b="";q.on("data",c=>b+=c);q.on("end",()=>{console.log(q.headers["webhook-id"],b);s.end("ok")})}).listen(8787)'
```

then add `http://localhost:8787/` and click **Send test**. Unit tests use the same idea (`packages/core/test/outbound-mock.ts`).
