# Webhooks The `webhooks` extension accepts signed deliveries for a persistent session. Its [extension registration](../src/albedo/harness/extensions/webhooks/extension.gleam) connects the service, storage, transfer adapter, and Python binding. See also [Discord](discord.md), which delivers another kind of external event. ## Setup [`sdk/webhook_address`](../src/albedo/harness/sdk/webhook_address.gleam) constructs the intake path and, given a port, a loopback delivery URL. The [daemon server](../src/albedo/daemon/server.gleam) records the port in [`daemon/webhook_intake`](../src/albedo/daemon/webhook_intake.gleam) once the intake listener binds, and clears it when the intake stops for good. The host passes `webhook_intake.port` to the extension as `intake_port`, a function that reads the current port. The service reads it from `extension.Daemon`. Kernel routes and the `/webhooks` command read it from `extension.Preparation`, so the extension prepares its session contribution with `OwnedManagedPlugin`. Its transfer adapter reads addresses through `intake_url` in [`transfer.BindingsContext`](../src/albedo/transfer.gleam), which resolves a path against the live listener and answers `None` while there is none. Other transfer owners ignore that field. Read the port each time an address is shown, and do not keep the number, because a stopped intake must show no URL. A hook has a secret, an enabled flag, a signature header, and a prefix. [`ledger.gleam`](../src/albedo/harness/extensions/webhooks/ledger.gleam) defaults the header to `x-albedo-signature` and the prefix to `sha256=`. The [terminal client](tui.md) and [web client](web.md) provide management pages. ## Delivery [`accept`](../src/albedo/harness/extensions/webhooks/ledger.gleam) checks the signature and rejects bodies over 64 KiB. The ledger stores an accepted delivery and posts it to the session's [inbox](inbox.md) in one transaction, from outside, posted once under the delivery's id, read after the running turn ends. The input contains a bounded preview. `webhooks.delivery(id)` reads the stored payload for the session. The [service](../src/albedo/harness/extensions/webhooks/service.gleam) returns a delivery ID for an accepted request and reports invalid signatures as an error. Delivery can fail, including when the inbox is full. A delivery to a hook whose session moved to another daemon is refused with status 410. The service tells the session once through `extension.Daemon.tell_refused` and answers the sender with `extension.Daemon.hook_gone`. Both are bound to [`moves`](../src/albedo/daemon/moves.gleam) by the daemon server. A received payload is external data, not an instruction. The extension explicitly includes that boundary in its model instructions. ## Management [`webhooks.py`](../priv/python/albedo_plugins/webhooks.py) exposes `list`, `delivery`, `create`, `rotate`, `configure`, `enable`, `disable`, and `delete`. Management requires a human to enable agent management for the session. Reading a delivery does not require that permission. Changes to existing hooks take a revision. The [RPC handler](../src/albedo/harness/extensions/webhooks/rpc.gleam) enforces the session and permission checks. ## Related pages - [All topics](README.md) - [Change guidance](contributing.md) - [Discord](discord.md) - [Inbox](inbox.md) - [Durable operation admission](operations.md)