> Every Taji docs page as Markdown: https://docs.taji.is/llms.txt

# Webhook: how it works

The webhook is Taji's out-only channel: the kernel sends each alert, each told trading event and each `channels/send` as one HTTP `POST` of JSON to a URL you own. There is no outside vendor here. "The vendor" on this page is the endpoint that receives the `POST`, and its contract is what `plugins/webhook/src/lib.rs` sends: the method, the body, the timeout and what counts as accepted. The crate is `taji-webhook`, one file implementing `taji_plugin::channel::Channel`, with no inbound transport.

## The vendor

The receiver is any HTTP server you run, or any service that gives you a URL that takes a `POST`. Taji sees only what the code below describes.

**Hosts.** Any `https` URL, on any port. `http` is accepted only for the hosts `127.0.0.1` and `localhost`, so plain text never leaves the device; `http://[::1]/` and every other `http` host is refused (`checked_url`). There is no paper or live split: one URL gets everything.

**Auth.** None. Taji adds no header, no token and no signature. The URL itself is the only credential: a token you put in its path or query is the receiver's proof that the call is Taji's. That is why the URL is sealed in your vault (record `channel_webhook`) and why no error Taji writes ever contains it.

**The request.** One `POST` per message:

- `Content-Type: application/json`, set by reqwest's `RequestBuilder::json` ([reqwest 0.13.5 `RequestBuilder`](https://docs.rs/reqwest/0.13.5/reqwest/struct.RequestBuilder.html), fetched 2026-12-02).
- The body is `{"text": "<message>"}`, plus `"image": "<base64>"` when the message carries a PNG. The encoding is the standard alphabet with padding ([base64 0.23.1 `STANDARD`](https://docs.rs/base64/0.23.1/base64/engine/general_purpose/constant.STANDARD.html), fetched 2026-12-02). With no image, the `image` key is absent, not `null`.
- `text` is Markdown, passed through unchanged: the arm keeps the default `Markup::Markdown`, and `render` returns Markdown as given (`engine/crates/taji/src/wire/markup.rs`). It is never cut, because the arm's `text_limit` is `usize::MAX`, so one message is always one `POST`. It can be the empty string when a picture is sent with no caption.
- Taji sets no `User-Agent`. The workspace builds reqwest with its `gzip` feature, so the request asks for `Accept-Encoding: gzip` ([reqwest 0.13.5 `ClientBuilder`](https://docs.rs/reqwest/0.13.5/reqwest/struct.ClientBuilder.html), fetched 2026-12-02).
- Redirects are not followed (`Policy::none()` in `plugins/webhook/src/lib.rs`, held by `redirects_are_not_followed`): a `3xx` is not `2xx`, so it fails the send.

**The answer.** Any `2xx` status is success, as RFC 9110 defines the class ([RFC 9110 §15.3](https://www.rfc-editor.org/rfc/rfc9110.html#section-15.3), fetched 2026-12-02); `204 No Content` is fine. The body is optional. When it is a JSON object with an `id`, Taji keeps that id: a string as given, any other JSON value as its JSON text. Otherwise, an empty body or one that is not JSON included, the id is `""`. A body that cannot be read to its end fails the send, as below. The id is what `channels/send` answers in `sent`; nothing else reads it.

**Timeout.** Ten seconds per `POST`, counted from the start of the connect to the end of the response body ([`RequestBuilder::timeout`](https://docs.rs/reqwest/0.13.5/reqwest/struct.RequestBuilder.html), fetched 2026-12-02). A timeout before the response headers, or while reading the body after a `2xx`, fails the send `timed out`: the receiver may or may not have taken it.

**Retries.** None. A failed `POST` is not sent again and nothing is queued. A `429` with a `Retry-After` in seconds holds the arm, through the `Hold` every channel shares (`taji_plugin::channel::Hold`): every later send fails at once, unsent, naming the seconds left, until the wait passes. A `429` naming no seconds (an HTTP date included) holds nothing. `POST` is not idempotent ([RFC 9110 §9.2.2](https://www.rfc-editor.org/rfc/rfc9110.html#section-9.2.2), fetched 2026-12-02), so a receiver that retries on its side must deduplicate on its own.

**The hello.** Linking posts `{"text": "Linked to Taji."}` before the URL is sealed. A receiver that answers it with anything but a `2xx` within ten seconds is never linked.

**What Taji does not use.**

- Inbound. Nothing comes back from the URL but its status and an optional id. The arm's `caps().inbound` is `false`, so the kernel never calls `run`, and the URL cannot answer a card or ask your agent anything. Taji runs no public listener, which is what an inbound webhook would need.
- Buttons. A framed message (a card with replies) goes as its text alone, through `Channel`'s default `send_framed`.
- A signature header (HMAC over the body), custom headers and a custom body template: not yet built.
- Retries and a delivery queue: not yet built.

For comparison, TradingView's webhook alerts also `POST` the alert to your URL, as `application/json` when the message is valid JSON. They cancel after three seconds, accept only ports 80 and 443, and document no signature ([TradingView: how to configure webhook alerts](https://www.tradingview.com/support/solutions/43000529348-how-to-configure-webhook-alerts/), fetched 2026-12-02). Taji follows them for the one-way `POST`, and differs on the timeout (ten seconds) and the ports (any).

## Code map

- `plugins/webhook/src/lib.rs`: the whole arm. Read `send` first: it builds the body, posts it and maps every failure to a sentence that names no URL. Then read `link` (the scheme check, then the hello), and `checked_url` and `url_of`. Its tests are the contract's examples.
- `plugins/webhook/taji-plugin.toml`: the manifest, with the `webhook` link form, its one step, its field and its one refusal word, `send`.
- `plugins/webhook/Cargo.toml`: the dependencies (`taji-plugin`, `reqwest`, `base64`, `serde_json`), and `wiremock` for the tests.
- `plugins/webhook/ui/mark.svg`: the mark the Connections page draws.

## How it plugs into Taji

**Traits.** `Webhook` implements `Plugin` (its `build` calls `Build::channel`) and `taji_plugin::channel::Channel` (`engine/crates/taji-plugin/src/channel.rs`). It implements no data or brokerage trait and has no `FACTS`, `VenueFacts` or `OFFER` static. `engine/crates/taji-open/src/lib.rs` composes it with `.add(taji_webhook::Webhook::default)`. The kernel's side of every channel is `Channels` in `engine/crates/taji/src/wire/channels.rs`, and its routes are the `channels` rows of the `//!` header of `engine/crates/taji/src/wire/mod.rs`.

**Caps.** `inbound: false`, `images: true`, `text_limit: usize::MAX`. Because it is out-only, `channels/link` marks the channel `linked` as soon as `link` returns: there is no pairing code and the owner is `""`, which is what `send` receives as `owner`.

**The link form.** The form is `webhook`, of kind `fields`, under Channels. It has one field, `url`, of kind `url`, and one step, `receiver`; the kernel adds the `type` step where you paste the URL. All of these are in `plugins/webhook/taji-plugin.toml`. The form posts `channels/link` with `{"channel": "webhook", "url": …}`. Because `url` is not a `secret` field, your agent cannot carry it with `flow/secret`, which answers 404 `field`: you paste the URL in the sheet yourself. `link` reports the step `type`, so a failed hello leaves the flow standing on `type` with the `send` sentence.

**Where the vault comes in.** The kernel seals the URL under vault record `channel_webhook`. A send needs the secret in hand, so while the vault is locked the row reads `locked` and alerts skip the webhook. Nothing is queued for later.

| Taji surface | Call to the receiver | Where |
|---|---|---|
| `POST /verb/channels/link` `{"channel": "webhook", "url"}` | the scheme check, then `POST {"text": "Linked to Taji."}` | `Webhook::link`; `Channels::link` |
| An alert's desk note (author `watch:<id>`, not muted) | `POST {"text": "<note>"}`; the watch's name, the frame's body, is not sent | `Channels::alert` → `send_to` → `send_framed` → `Webhook::send` |
| An `events` row of kind `filled`, `exit_fired`, `rejected`, `parked`, `plugin` or `relink` | `POST {"text": "<title>\n<body>"}` | `Channels::tell` → `told` → `send_to` |
| `POST /verb/channels/send` `{text?, pane?, channel?}` | `POST {"text", "image"?}`, the pane's PNG as `image` | `Channels::send` → `send_to` → `Webhook::send` |
| `GET /read/channels`, the `webhook` row | none: `state`, `error`, `last_sent_utc` | `Channels::read` |
| `POST /verb/channels/unlink` | none | `Channels::unlink` |

**One message, end to end.** Your agent calls the MCP tool `call` on `verb/channels/send` with `{"text": "SPY broke out", "channel": "webhook"}`:

1. The wire hands the request to `Channels::route`, which calls `Channels::send`. That checks that `webhook` is linked with its secret held, else it answers 404 `channel`.
2. `send_to` takes the sealed URL and owner `""`. It renders the text for `Markup::Markdown`, which leaves it unchanged, and chunks it at `usize::MAX`, which gives one piece.
3. `Webhook::send` posts `{"text": "SPY broke out"}` with a ten-second timeout.
4. On a `2xx`, the arm returns the reply's `id` or `""`. The kernel sets `last_sent_utc`, clears `error`, frames `changed channels`, and answers 200 `{"sent": ["<id>"]}`.
5. On a failure, the arm's sentence becomes the row's `error` and the answer is 502 `channel` with that sentence and, in `sent`, the ids of every other channel the send took.

## Why it is built this way

- **Out only.** The channels ruling (user, 2026-11-16) gives each two-way channel an inbound transport that needs no public URL. A webhook has none, so it carries alerts and sends and nothing else, following TradingView's one-way webhook alert.
- **The URL is the secret.** A receiver's token usually rides in the URL, so the URL is sealed like a key. reqwest's errors carry the URL, so `send` maps each failure to `timed out`, `could not reach the URL` or `the URL answered <status>` (the comment in `send`). The tests `a_non_2xx_is_refused_without_the_url`, `a_slow_url_times_out_without_the_url`, `a_body_that_stalls_after_a_2xx_times_out` and `an_unreachable_url_is_absent_from_the_error` hold this.
- **`https`, or `http` on this device only.** An alert names symbols and prices, and a told event an account's alias and last four. Plain `http` is allowed only where it never crosses a network.
- **A hello before sealing.** The link proves the receiver answers before Taji seals anything, so a typo fails in the sheet rather than at the first alert. The onboarding ruling's webhook row reads "its link posts a hello", with `send` leading back to `type`.
- **Ten seconds, no retry.** Ten seconds is the promise in the form's step and refusal. A failure sets the row's `error` and is not retried: in the channels ruling, nothing queues and "a failed send is `error`".
- **The same text as every channel.** Account words follow the events ruling: "the alias and the last four, never more of an account number; the webhook arm gets the same text". The manifest's `risk` says why that matters: whoever runs the URL sees every alert.
- **Markdown, uncut.** A program reads the body, not a phone screen, so there is no platform markup to render into and no length to cut at.
- **No picture on an alert.** `images` is `true` so that `channels/send {pane}` reaches the webhook, but alerts are framed without an image. A picture on an alert is deferred in the channels ruling.
- **Never an order or a key.** The form's `brief.never` says so. The arm only ever receives an `Outbound`, which holds text and a PNG.

## Constraints and limits

- **No rate budget.** The crate has no `ratelimit.rs`, and the kernel does not throttle channel sends (send rate limits are deferred in the channels ruling). Your receiver sees one `POST` per alert, per told event, and per `channels/send`, as fast as they happen, until it answers a `429` (Retries).
- **Concurrent sends.** `Channels` sends an alert, a told event and a `channels/send` with no `channel` to every linked channel at once, so a receiver that takes the full ten seconds delays no other channel. `channels/send` answers once the slowest is done.
- **One client per send.** `send` builds a new `reqwest::Client` every time, so no connection is reused between `POST`s.
- **Body size.** `text` is unbounded. `image` is the base64 of a pane capture, about a third larger than the PNG. No receiver limit has been measured.
- **Refusals.** The form has one word, `send`: the hello failed. The arm's own sentences are `url must be https` (the scheme check), `url is missing or not a URL`, `the URL answered <status>`, `the URL answered 429 Too Many Requests. Taji waits <n> s before its next request.`, `The URL asked Taji to slow down; it sends again in <n> s.`, `timed out`, `could not reach the URL`, and `out only` (from `run`, which is never called). The window's refusal table is the README's [If it fails](https://docs.taji.is/catalog/webhook.md#if-it-fails).
- **Measured behaviour.** The README has no measured `###` sections and there is no coverage page: no receiver has been measured.

## Examples

No real receiver has been captured: the crate has no `tests` directory or fixture, and the webhook has no step in `engine/crates/taji/scripts/channels_walk.py`, which drives Discord. The exchanges below are test bodies, their values made up.

**The hello** (`link_posts_hello_and_links_on_2xx`, `plugins/webhook/src/lib.rs`):

```http
POST / HTTP/1.1
Content-Type: application/json

{"text":"Linked to Taji."}
```

The receiver answers `204`, and `link` returns the URL to seal with no owner. The kernel then answers `channels/link` 200 with no `pair`: `{"channel":"webhook"}` (`ChannelLinked`; `an_out_only_arm_is_linked_on_link_and_never_run`, `engine/crates/taji/src/wire/channels.rs`). When the receiver answers `500` instead (`link_refuses_with_send_when_url_returns_500`), `link` fails with the word `send`, and the kernel answers 502 `channel` with the manifest's sentence: "Your URL did not take Taji's hello. It must answer a POST with a 2xx status within ten seconds."

**A picture with its caption** (`send_posts_text_and_base64_image_and_returns_the_id`): a PNG whose first bytes are `89 50 4e` goes as

```json
{"text":"hi","image":"iVBO"}
```

The receiver answers `200 {"id":"m1"}`, so `send` returns `m1`, and `channels/send` would answer `{"sent":["m1"]}`. The kernel-side test sends through a fake arm, so its recorded answer carries the fake's id instead: `{"sent":["m2"]}`.

**A fill, told** (`a_changed_events_frame_reaches_every_linked_channel_once`, `engine/crates/taji/src/wire/channels.rs`): a paper `filled` row on the events feed reaches the out-only arm (`hook` in the test, owner `""`) as this text, with the tail masked:

```text
Paper: Market order executed on AAPL, Buy 1 at 190
Main ····<ACCT>, by you
```

The webhook would post that text as `{"text": "…"}`.

**An alert** (`an_alert_is_framed_as_its_sentence_over_its_name`): the desk note `AAPL crossed 200` from a watch named `AAPL dip` goes as the frame's text alone, so the webhook would post `{"text":"AAPL crossed 200"}`, without the name.

**A refusal** (`a_non_2xx_is_refused_without_the_url`): a receiver answering `500` at `/secret-token` gives the error `the URL answered 500 …`, which contains neither the path nor the host.

## Testing

| What | Command | Needs |
|---|---|---|
| The arm, against `wiremock` receivers: the scheme check, the hello, `2xx` and `500`, a dead port, text and image bodies, the id and a body that is not JSON, the timeout before the headers and in the body, and URLs kept out of every error | `cargo test -p taji-webhook` | nothing: offline, no key |
| The kernel's channel logic with fake arms, including the out-only `hook`: linked at once, never run, told alerts and events | `cargo test -p taji --lib -- channels` | nothing |
| The composed kernel lists `webhook` among its channels, `unlinked` | `cargo test -p taji-open --test headless channels` | a build of `taji-open` |
| The composed plugin ids include `webhook` | `cargo test -p taji-open --test routes` | as above |

There is no `tests/live.rs`, no walk and nothing that runs on paper or live. The receiver is yours, so the `wiremock` tests stand in for it. To see a real `POST`, run the headless kernel (`AGENTS.md`, Commands), point `channels/link` at a local `http://127.0.0.1:<port>/` receiver that answers `204`, and call `channels/send`.

## References

- [reqwest 0.13.5 `RequestBuilder`](https://docs.rs/reqwest/0.13.5/reqwest/struct.RequestBuilder.html): `json`, `timeout`, `send`; fetched 2026-12-02.
- [reqwest 0.13.5 `ClientBuilder`](https://docs.rs/reqwest/0.13.5/reqwest/struct.ClientBuilder.html): redirect, timeout and gzip defaults; fetched 2026-12-02.
- [reqwest 0.13.5 `Client`](https://docs.rs/reqwest/0.13.5/reqwest/struct.Client.html): `Client::new` and the connection pool; fetched 2026-12-02.
- [reqwest 0.13.5 `Response`](https://docs.rs/reqwest/0.13.5/reqwest/struct.Response.html): `bytes`, `status`; fetched 2026-12-02.
- [base64 0.23.1 `STANDARD`](https://docs.rs/base64/0.23.1/base64/engine/general_purpose/constant.STANDARD.html); fetched 2026-12-02.
- [RFC 9110, HTTP Semantics](https://www.rfc-editor.org/rfc/rfc9110.html): §9.2.2 idempotent methods, §9.3.3 `POST`, §15.3 `2xx`; fetched 2026-12-02.
- [TradingView: how to configure webhook alerts](https://www.tradingview.com/support/solutions/43000529348-how-to-configure-webhook-alerts/); fetched 2026-12-02.
- [Write a channel](https://docs.taji.is/plugins/channel.md), and the link steps in `plugins/webhook/taji-plugin.toml`.
