# Receive governance webhooks

Subscribe an HTTPS endpoint to governance events, verify each signed request, and handle retries, duplicates and replacing a secret.

A governance webhook is an HTTPS `POST` the platform sends to your endpoint when a governance event happens in your workspace: an operation is held for approval, a reviewer decides, a run is refused. Each request is signed with its subscription's secret.

Availability

Governance webhooks are available in every workspace; no switch has to be on. Only a workspace admin signed in to the web workspace can list, create, change, test or remove subscriptions; API keys cannot.

## Create a subscription

- As a workspace admin, open **Settings → Alerts & webhooks** in the web workspace and find the card **Governance-event webhooks**.

- Enter an absolute `https` URL under **Endpoint URL (https only)**.

- Select the types you want under **Event types**. The form preselects **Agent published**, the one type not sent today.

- Select **Add subscription**. The secret, which starts with `whsec_`, appears once under **Signing secret — copy it now, it will not be shown again**.

Each subscription shows the last four characters of its secret, with **Disable** (or **Enable**), **Send test event** and a remove button. It cannot be edited: remove it and add a new one, which issues a new secret. An event goes to every enabled subscription listing its type. Subscription changes and tests are recorded in the [audit log](https://centerofagentic.com/docs/api/receipts#audit-log).

Not alert channels

The **Alert channels** card in the same section sends hourly, aggregated [alerts](https://centerofagentic.com/docs/api/monitoring#alerts). Its webhook requests are unsigned and have a different body.

## Event types

| Type (label in Settings) | Sent when | `detail` |
| --- | --- | --- |
| `approval.requested` (**Approval requested**) | A background job, or a run with Deep Agents delegation (off by default), holds operations for a reviewer. | `jobId`, `heldActions` (tool names as offered to the model, such as `c0__create_email`), `holdExpiresAt`, and `rounds` or, with delegation, `rootJobId` and `depth`. |
| `approval.granted`, `approval.denied` (**Approval granted**, **Approval denied**) | A workspace admin approves or denies a held operation. | `jobId`, `callId`, `resolvedBy` (the reviewer's user id), `note`; with delegation also `rootJobId` and `depth`. |
| `run.denied` (**Run denied**) | `POST /api/run` refuses a run by policy, or any run endpoint refuses one because the agent is revoked or a model call is refused. | `reasonCode`; `revoked` is `true` for a revoked agent. |
| `agent.revoked` (**Package revoked**) | A workspace admin revokes a published agent whose `grantLifecycle` is `legacy_unadopted`. Revoking an agent under managed activation sends nothing today. | `from`, `version`, `name`. |
| `authority_creep` (**Authority creep**) | The hourly alert evaluation finds that an agent's newest version grants more authority or less oversight than the previous one. Sent once per finding, only in a workspace with an enabled alert channel. | `escalations`, `critical`, `fromVersion`, `toVersion`. |
| `evidence.inconsistent` (**Desktop evidence inconsistent**) | The desktop app syncs a run record whose decision differs from the server's own evaluation. | `receiptId`, `reported`, `server`. |
| `agent.published` (**Agent published**) | Never: selectable, but not sent today. | None. |

- `run.denied` does not cover every refusal. Nothing is sent for policy refusals on the streaming, background-job and conversation endpoints, connection refusals, the budget check at the start of a run (`SPEND_OVER_BUDGET`), or a launch ticket refused because an activated agent is paused or revoked. `GET /api/receipts?decision=deny` lists refused runs.

- A hold that expires undecided sends no event; `GET /api/approvals` lists what is still held.

## The delivery request

Each delivery is one `POST` with a compact JSON body of at most 64 KiB.

| Header | Value |
| --- | --- |
| `Content-Type` | `application/json` |
| `X-Signature` | The HMAC-SHA256 of the request body, as 64 lowercase hexadecimal characters. |
| `X-Signature-Algorithm` | `hmac-sha256` |

Do not rely on any other request header.

| Body field | Type | Meaning |
| --- | --- | --- |
| `id` | string | Identifies the event; identical on every retry. Treat it as opaque. |
| `type` | string | The event type. |
| `tenantId` | uuid | Your workspace id. |
| `firedAt` | ISO 8601 date-time | When the event happened. |
| `agentId` | uuid or `null` | The agent concerned, if any. |
| `detail` | object | Depends on the type. Empty on a retry. |

```json
{
  "id": "run-approval-requested:b7a4d2f0-3c1e-4a8b-9d6f-2e5c8a1b4d73:2",
  "type": "approval.requested",
  "tenantId": "9b2d4c1e-7a3f-4f0b-8c6d-2e5a1b0f9c33",
  "firedAt": "2026-11-27T14:02:11.482Z",
  "agentId": "3f1c2a9e-0b7d-4e55-9a51-6f2f1c0e8d11",
  "detail": {
    "jobId": "b7a4d2f0-3c1e-4a8b-9d6f-2e5c8a1b4d73",
    "heldActions": ["c0__create_email"],
    "rounds": 2,
    "holdExpiresAt": "2026-11-28T14:02:11.480Z"
  }
}
```

## Verify the signature

- Read the request body as raw bytes, before any JSON parsing. Re-serialized JSON does not match.

- Compute HMAC-SHA256 over those bytes, keyed with the whole secret string including `whsec_`, as UTF-8.

- Hex-encode the result and compare it with `X-Signature` in constant time.

- On a mismatch, answer `401` and discard the request.

Both receivers read the secret from `COA_WEBHOOK_SECRET`, verify, answer `204`, then process the event. They listen on plain HTTP on `127.0.0.1:8080`, so put them behind your TLS-terminating proxy, which must pass the body through unchanged.

```python
"""Receive governance webhooks. Python 3.9 or later, standard library only."""
import hashlib
import hmac
import json
import os
import queue
import threading
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer

SECRET = os.environ["COA_WEBHOOK_SECRET"].encode("utf-8")  # the whole whsec_ string
MAX_BODY = 64 * 1024
events = queue.Queue()
seen = set()  # use a durable store in production


def signature_ok(raw: bytes, received: str) -> bool:
    expected = hmac.new(SECRET, raw, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected.encode("ascii"), received.encode("utf-8"))


def process_events() -> None:
    while True:
        event = events.get()
        try:
            if event["id"] in seen:  # a retry of an event already handled
                continue
            seen.add(event["id"])
            print(event["type"], event["id"], event["agentId"], event["detail"], flush=True)
        except Exception as err:  # already acknowledged: log it and keep the worker alive
            print("webhook processing failed:", repr(err), flush=True)


class Receiver(BaseHTTPRequestHandler):
    def do_POST(self) -> None:
        try:
            length = int(self.headers.get("Content-Length", ""))
        except ValueError:
            length = 0
        if not 0 < length <= MAX_BODY:
            self.reply(400)
            return
        raw = self.rfile.read(length)  # the exact bytes that were signed
        if not signature_ok(raw, self.headers.get("X-Signature", "")):
            self.reply(401)
            return
        events.put(json.loads(raw))  # verified: queue it and answer at once
        self.reply(204)

    def reply(self, code: int) -> None:
        self.send_response(code)
        self.send_header("Content-Length", "0")
        self.end_headers()


if __name__ == "__main__":
    threading.Thread(target=process_events, daemon=True).start()
    ThreadingHTTPServer(("127.0.0.1", 8080), Receiver).serve_forever()
```

```ts
// Receive governance webhooks. Node.js 18 or later; imports only built-in modules.
import { createHmac, timingSafeEqual } from "node:crypto";
import { createServer } from "node:http";

const SECRET = process.env.COA_WEBHOOK_SECRET ?? ""; // the whole whsec_ string
if (!SECRET) throw new Error("COA_WEBHOOK_SECRET is not set");
const MAX_BODY = 64 * 1024;

type GovernanceEvent = {
  id: string;
  type: string;
  tenantId: string;
  firedAt: string;
  agentId: string | null;
  detail: Record<string, unknown>;
};

const seen = new Set<string>(); // use a durable store in production

function signatureOk(raw: Buffer, header: string | string[] | undefined): boolean {
  if (typeof header !== "string") return false;
  const expected = createHmac("sha256", SECRET).update(raw).digest();
  const received = Buffer.from(header, "hex");
  return received.length === expected.length && timingSafeEqual(received, expected);
}

async function processEvent(raw: Buffer): Promise<void> {
  const event = JSON.parse(raw.toString("utf8")) as GovernanceEvent;
  if (seen.has(event.id)) return; // a retry of an event already handled
  seen.add(event.id);
  console.log(event.type, event.id, event.agentId, event.detail);
}

createServer((req, res) => {
  const chunks: Buffer[] = [];
  let size = 0;
  req.on("data", (chunk: Buffer) => {
    size += chunk.length;
    if (size <= MAX_BODY) chunks.push(chunk);
  });
  req.on("end", () => {
    const raw = Buffer.concat(chunks); // the exact bytes that were signed
    if (req.method !== "POST" || size > MAX_BODY || !signatureOk(raw, req.headers["x-signature"])) {
      res.writeHead(401).end();
      return;
    }
    res.writeHead(204).end(); // verified: answer at once, then work
    processEvent(raw).catch((err) => console.error("webhook processing failed:", err));
  });
}).listen(8080, "127.0.0.1");
```

### Check a receiver locally

Set `COA_WEBHOOK_SECRET` to a made-up value such as `whsec_local_check_only`, not the real secret, and start a receiver: `python3 receiver.py`, or `node receiver.ts` on Node.js 22.18 or later (on older versions, `npx tsx receiver.ts`). With the same value in a second terminal, this command prints `204`; alter the body after signing and it prints `401`.

```bash
BODY='{"id":"test-1795788131482","type":"webhook.test","tenantId":"9b2d4c1e-7a3f-4f0b-8c6d-2e5a1b0f9c33","firedAt":"2026-11-27T14:02:11.482Z","agentId":null,"detail":{"message":"local check"}}'
SIGNATURE=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$COA_WEBHOOK_SECRET" | awk '{print $NF}')

curl -sS -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8080/ \
  -H "Content-Type: application/json" \
  -H "X-Signature: $SIGNATURE" \
  -H "X-Signature-Algorithm: hmac-sha256" \
  --data-binary "$BODY"
```

## Respond first, process afterwards

Any `2xx` counts as delivered; the response body is ignored. Anything else is a failure: any other status (redirects are not followed), a connection, TLS or DNS error, or a request that stalls for 8 seconds. The first attempt is sent while the platform completes the action behind the event, so acknowledge at once. Answer `2xx` for types you do not handle, including `webhook.test`.

## Retries

| Failed attempt | Wait before the next |
| --- | --- |
| 1 (sent when the event happens) | 5 minutes |
| 2 | 15 minutes |
| 3 | 1 hour |
| 4 | 4 hours |
| 5 | None: the delivery is marked failed. |

- A job sends due retries once an hour, so each wait rounds up to that job's next pass, or to a later pass when many retries are due.

- A retry keeps the `id`, `type`, `tenantId` and `agentId`, but its `detail` is empty and its `firedAt` is the time the delivery was first queued. The signature matches the body as sent. No API call returns an event by its `id`, so treat a retry as a signal to reconcile: `GET /api/approvals` lists the holds still waiting, `GET /api/receipts?decision=deny` the refused runs, and the [audit log](https://centerofagentic.com/docs/api/receipts#audit-log) the decisions reviewers made.

- A subscription is never disabled automatically.

- A waiting retry is dropped if its subscription has been removed, or is disabled when the retry comes due. Events that happen while a subscription is disabled are never sent.

- There is no delivery history to read; log what you receive.

## Ordering and duplicates

- **No ordering.** A retried event can arrive hours after later events.

- **Duplicates are possible.** A delivery recorded as delivered is not sent again, but if your endpoint handled a request and no `2xx` arrived in time, the event is retried. Make processing idempotent on `id`.

- **Delivery is not guaranteed.** Reconcile against [receipts, approvals and the audit log](https://centerofagentic.com/docs/api/receipts) for anything you must not miss.

## Send a test event

**Send test event** sends one signed request with `type` set to `webhook.test`, an `id` starting with `test-`, `agentId` set to `null` and a `message` in `detail`. The web workspace shows **Test event delivered** with your endpoint's HTTP status, or **Test failed** with the reason. A test is never retried, and is sent even to a disabled subscription.

## Security

Verify before you trust

Anyone who learns the URL can post to it. Check `X-Signature` on every request before you parse or act on the body.

- **HTTPS only.** A URL that is not `https` is refused when saved and at delivery. Delivery also refuses private, loopback and link-local addresses and local hostnames such as `localhost`, so the endpoint must be publicly reachable.

- **Guard the secret.** Whoever holds it can forge events, and it cannot be changed. To replace it without missing events, add a second subscription with the same URL and types, verify against either secret, then remove the old one. Meanwhile each event arrives twice with the same `id`.

- **Replays.** Only the body is signed and no timestamp header is sent: record the `id` values you processed and ignore repeats. `firedAt` is not the send time: a fifth attempt comes at least 5 hours 20 minutes after it, so a tight freshness window rejects real deliveries.

- **Payloads are governance data.** They carry agent ids, reason codes, reviewer ids and notes. Restrict access to your receiver's logs.

## Next steps

- [**Monitoring, alerts and webhooks** Reference for subscriptions, alerts and metrics.](https://centerofagentic.com/docs/api/monitoring#governance-webhooks)

- [**Export evidence for review** Page through receipts and read the audit log.](https://centerofagentic.com/docs/guides/audit-evidence)

- [**Run an agent** Background jobs, held operations and reason codes.](https://centerofagentic.com/docs/guides/run-an-agent)

Source: https://centerofagentic.com/docs/guides/webhooks

## Related pages

- [audit log](https://centerofagentic.com/docs/api/receipts#audit-log)
- [alerts](https://centerofagentic.com/docs/api/monitoring#alerts)
- [receipts, approvals and the audit log](https://centerofagentic.com/docs/api/receipts)
- [Monitoring, alerts and webhooks Reference for subscriptions, alerts and metrics.](https://centerofagentic.com/docs/api/monitoring#governance-webhooks)
- [Export evidence for review Page through receipts and read the audit log.](https://centerofagentic.com/docs/guides/audit-evidence)
- [Run an agent Background jobs, held operations and reason codes.](https://centerofagentic.com/docs/guides/run-an-agent)
