[SEND][ACK]

Sendack's API (the prototype, sendack-proto serve)

On central at https://sendack.lunaor.com. Everything here is served by one process; the Connect API is the one to build on (binary protobuf, proto/sendack/v1/api.proto and event.proto, so clients are generated); the JSON and WebSocket routes beside it carry the same machinery.

Auth

With --harpora-issuer, every call carries Authorization: Bearer <Harpora access token> whose audience is the API's (https://sendack.lunaor.com on central). Without it the server is open (a local server, the proofs): it then listens only on loopback unless started with --open yes, and refuses flags that mean something only with tokens. Every binary refuses a flag it doesn't take, and a server logs its effective settings (no secrets) as it starts.

  • Getting a token: sendack-proto keygen and sendack-proto token (quickstart step 1).
  • Services by scope: sendack:topic:<name>:publish / :subscribe (* is any one whole topic name), sendack:subscription:<name>:use, sendack:webhooks:create, sendack:notify:rules.
  • Retention by sendack:topic:<name>:admin (or an org admin or owner, or FGA admin on topic:<name>).
  • People by Harpora's FGA, when their token has no Sendack scope: reader on topic:<name> to read and follow, writer to publish (the realm's model: decisions.md, "The realm's FGA model").
  • Customers (6 Dec 2026): a server started with --customer-issuer <URL> (sendack.dev's realm, https://auth.lunaor.com/sendack) takes that realm's tokens for the same audience too, but a customer's token holds no scope of its own, whatever it claims: no topic scope, no staff or operator grant, never a machine. A customer reaches only what their orgs give them, by their verified email (email:<address>) or as sub:customer:<their subject> (their subjects are a namespace of their own). A customer's agent can't take a nod-level action yet: the approval would come from the staff realm, which doesn't know it.
  • A stream ends when its token expires (unauthenticated); resume from the last position with a fresh token.
  • A WebSocket from a browser (no headers) sends {"token": "…"} as its first frame (close 4001 refused, 4003 not allowed). A close carries a reason saying what to fix: on 4001 the verifier's own, as the HTTP 401 gives it (cut to the 123 bytes a close frame holds).

Limits

With tokens checked (--harpora-issuer), each past its limit is 429 (resource_exhausted on the Connect API); flags override them:

LimitDefaultFlagPast it
Webhooks one service makes (counted by the token's subject)100--max-webhooks-per-serviceWebhooks/Create, PUT /webhooks/{name}: 429; delete one first (re-creating an existing name isn't counted)
Live sockets one person holds on a server (WebSockets and Live/Subscribe streams of callers admitted by FGA; a service subscribing by scope is never counted)50--max-sockets-per-person429 on the upgrade or the stream; a first-frame token past it: close 4029
WebSockets on a server still waiting for their first-frame token10,000--max-pending-sockets429 on the upgrade; try again shortly
Functions an org has (functions.rs, --functions yes)50--max-functions-per-orgPUT /functions/{name}: 429; unbind one first (0 allows none)
Functions on one topic, or on one prefix5--max-functions-per-topicPUT /functions/{name}: 429; unbind one first (0 allows none). A prefix binding counts toward its prefix, not the topics under it

A function's pusher also starts at most --function-starts-per-second (20; 0 is none) runs a second; over it the pusher waits and drops nothing (it is not a refusal anyone sees).

Publishing to a topic with a notification rule (each event can notify up to 10,000 people) is rate-limited per publisher (the token's subject) and topic: a bucket of --rule-publish-burst (50) events, refilled at --rule-publish-rate (10) a second; 0 turns it off. An empty bucket answers 429 (resource_exhausted) with Retry-After in seconds, except to a person publishing one event (POST /publish/{topic}/{id}, Topics/Publish), who is held for a nod naming that event instead (403 with Nod's challenge, Nod approvals); an approved event takes nothing; a batch (POST /publish-batch/{topic}, Topics/PublishBatch) takes one per event, and a batch larger than the burst is 400. Topics without a rule are never limited. Dead letters a pull moves onto a ruled topic take from the puller's bucket there (those past it stay due for a later pull). A new rule is limited, and a deleted one freed, within about a second; a server lists the rules before it serves, so its first publishes are limited too. Per server, like the limits above.

Publisher

Every event records who published it, publisher: the access token's subject (sub, or a service's client id), set by the server and never taken from the request (a publish has no such field; one in the data is just data). Readers get it beside the data on every route (Delivered and Pulled field 5, the WebSocket and pull JSON, a webhook's body, and publisher on the Rust, TypeScript and Python clients' events), so an app can check the data's own claims, such as a chat message's from, against it. It's empty on an open server, on events published before the field existed, and on dead letters (a subscription's maker moved them; the original publisher never published to that topic). A rule's notifications carry the event's publisher in their JSON (a publisher the event's data claimed is dropped), are published by sendack, and never notify the publisher. Agent messages (the adapter): the sending agent (<person>-agent), and for an <id>.read event the agent that read it.

Positions

Every event has a position, <version>.<n>: its commit's version, then its place in that version. Ordered, exact, the same from every route (Publish's answer, Read, Live, pulls, webhooks); resume anything with the last position you saw and you get exactly what came after. Keep positions as strings and send them back as they are: compare them only as two numbers, version first.

Since the positions cutover (a version recorded once per database in sendack-meta/positions, when the first server numbering by order started), n is TwilightDB's order for the event's write (batch slot << 16 | place): unique and increasing within a version, but not consecutive. Events before the cutover keep the positions they always had (n their index among their version's changes), so positions held from before it still resume exactly.

Connect API

All POST, content-type: application/proto (unary) or application/connect+proto (streams, Connect's envelope).

MethodDoes
sendack.v1.Topics/Publish {topic, id, data, reply_to?}Publishes an event, answering {version, duplicate, pos} (pos its position, from TwilightDB's commit answer; the SDKs return all three from publish, pos null/None where a server has none); the same id again finds the first (duplicate, with its position), nothing is delivered twice; the same id from another publisher is 409 (already_exists), as other data is. data is at most 1,000,000 bytes (larger: 413 resource_exhausted; keep large content in FS3 and publish its reference).
sendack.v1.Topics/PublishBatch {topic, items: [{id, data, reply_to}]}POST /publish-batch/{topic} over Connect, the same operation through the same code: 1 to 1000 events (data is text, each up to the limit above) in one commit, answering {version, duplicate, positions} (positions: each event's position in the request's order, "" where a server has none); sent again it finds them all (duplicate); the same validation, rate bucket, ids and nod as the REST route, and reply_to per item ("": none) as REST's.
sendack.v1.Topics/Read {topic, after, limit, latest}History after after (empty: the beginning), up to limit (≤ 1000), then a clean end. latest: true: the newest limit, still oldest first. After a position it starts at that position's version (one seek, on TwilightDB 3c56135 or later), however long the topic.
sendack.v1.Live/Subscribe {topic, after}A hello (where it's live from), the catch-up after after (empty: from now), then live events. An unavailable end means resume. An after the database hasn't reached (a position from another database, or made up) is invalid_argument, never a stream that skips to it.
sendack.v1.Subscriptions/Create {name, topic, ack_deadline_s, max_attempts, dead_letter}A durable pull subscription from now. Made again under its name, it changes the ack deadline, attempts and dead-letter topic; its topic is fixed once made (another topic is 409: delete it and make it again). Its token needs the name's scope, the right to subscribe to topic, and the right to publish to dead_letter (scope or FGA, as for subscribing and publishing).
sendack.v1.Subscriptions/Pull {name, max}Leases up to max messages (one puller per message).
sendack.v1.Subscriptions/Ack / Nack {name, positions}Done / hand out again. Past max_attempts a message goes to the dead-letter topic. The JSON routes answer {acked, cursor} / {nacked}: how many of the positions were outstanding and are now acknowledged / due again, each once (a position not outstanding, or named twice, adds nothing); a store failure is unavailable (503), never a count of 0.
sendack.v1.Subscriptions/Seek {name, pos}Moves the cursor.
sendack.v1.Subscriptions/List {topic}The subscriptions the token may use (sendack:subscription:<name>:use, so a * scope lists them all), on topic if given: each a SubscriptionDetail {name, topic, cursor, leased_upto, ack_deadline_s, max_attempts, dead_letter, outstanding}.
sendack.v1.Subscriptions/Get / Delete {name}One's detail (outstanding: leased, not yet acked) / it and its leases. not_found if there's none.
sendack.v1.Webhooks/Create {name, topic, url}Delivers a topic to a URL, Svix-signed, in order, at least once; the secret is answered once. Needs sendack:webhooks:create and the right to subscribe to topic; names starting push-, rule- or email- are Sendack's own. A person (or an org member) whose org does not list the URL's host in limits.webhook_hosts gets the nod challenge (403) instead, and creates it once the call is repeated with the approval (Nod approvals).
sendack.v1.Webhooks/List {topic}Every webhook (sendack:webhooks:create, as for every webhook call), on topic if given: {name, topic, url, old_secret_until_ms}, never a secret.
sendack.v1.Webhooks/Get {name}As listed, plus subscription (its delivery state) and last ({at_ms, pos, ok, detail}: the last delivery tried, detail the receiver's status or why there was none).
sendack.v1.Webhooks/Delete {name}It, its subscription and leases; nothing more is delivered.
sendack.v1.Webhooks/RotateSecret {name, overlap_s, revoke_old}A new secret, answered once. The old one keeps signing beside it (webhook-signature: v1,<new> v1,<old>, as Svix does) for overlap_s (0: 24 h; at most 7 days), so the receiver switches without a gap; revoke_old stops it at once. Held for a nod unless the token is a service's own with the scope (Nod approvals).
sendack.v1.Notify/Key {}The Web Push applicationServerKey (base64url).
sendack.v1.Notify/Subscribe {endpoint, p256dh, auth, skip_when_live} / Unsubscribe {endpoint}A browser's push subscription for the token's person / its removal (another person's is not_found).
sendack.v1.Notify/GetPreferences {} / SetPreferences {push, quiet {from, to, tz}, email {to, delay_s}}The token's person's preferences (push absent means on; delay_s 0 means 900).
sendack.v1.Notify/PutRule / DeleteRule {topic}A topic's notification rule (scope sendack:notify:rules). Held for a nod unless the token is a service's own with the scope (Nod approvals).

The Notify calls share their handlers and auth with the JSON routes under /notify; person fields name the person only on an open server (with a token it's always the token's).

Each streamed message is a Delivered {pos, id, data, hello, publisher}; Subscriptions/Pull answers Pulled {pos, id, data, attempt, publisher}.

TypeScript client: sdk/typescript (@sendack/client): plain ESM on fetch, no dependencies or build (Node 18+, Deno, Bun, browsers, Workers). Publish, Read, Live.Subscribe (resumes by itself from its last position on unavailable, a dropped connection, 60 s of silence (idleMs) or an expired token, with a token function for refresh) and the Subscriptions methods, with the management calls (list, get, delete subscriptions and webhooks; rotate a webhook's secret; the Notify calls, event paging, webhook delivery history and redeliver); errors as SendackError {code, message, retryAfterS, wwwAuthenticate}. Its README has the shape; prove_sdk.mjs proves it against a server.

Rust client: crates/client (sendack-client), for services: the same calls (management included), subscribe() a futures::Stream that resumes by itself (also after 60 s of silence, SubscribeOptions.idle; a TokenSource or closure for fresh tokens), errors as sendack_client::Error {code, message, retry_after, www_authenticate}. The crate's docs have the shape; examples/prove_client.rs proves it against a server.

Python client: sdk/python (sendack), standard library only (Python 3.9+): the same calls, subscribe() an iterator that resumes by itself (also after 60 s of silence, idle; a token callable for fresh tokens), errors as SendackError(code, message, retry_after_s, www_authenticate). Its README has the shape; prove_sdk.py proves it against a server.

JSON and WebSocket routes

RouteDoes
POST /publish/{topic}/{id} (body: data; ?reply_to=<event id> for a reply: Threads)As Topics/Publish: {"version", "duplicate", "pos"}.
POST /publish-batch/{topic} [{"id","data","reply_to"?}…]Many events in one commit (as Connect's Topics/PublishBatch): {"version", "duplicate", "positions"}, a position per event in the batch's order. An item may carry reply_to ("" or absent: none), making it a reply in that event's thread, its thread link written in the same commit; the checks are a single reply's (parent missing 404, below the retention floor 410, itself a reply 400), and a parent that is an item of the same batch is 400 (a thread is one level, and a parent must already exist), all before anything is written: one bad item refuses the whole batch. On a topic with a notification rule, a person's batch past the rate is held for a nod for the whole batch (Nod approvals), a machine's is 429.
GET /live/{topic}?after=<pos> (WebSocket){"hello": pos}, then {"pos","id","data","publisher"} frames (publisher when known; reply_to on a reply: Threads). The client may send events back: below. An after the database hasn't reached is a 400 at the upgrade.
PUT /subs/{sub}, POST /subs/{sub}/pull, /ack, /nack, /seekAs the Subscriptions methods (data_b64 carries exact bytes; each pulled message also says its topic, which differs from the subscription's only on a function's prefix binding).
GET /subs?topic=, GET / DELETE /subs/{sub}As Subscriptions/List, Get, Delete. Names starting hook- are webhooks' own (400 here).
GET /subs/{sub}/dead?cursor=&limit=A subscription's dead letters (messages that ran out of max_attempts), oldest first, limit 1 to 100 (20): {sub, dead_letter, dead_letters: [{position, id, topic, attempts, error, at_ms, dead_topic, dead_id, data, bytes, truncated}], next_cursor}. position and id are the message's on topic, the subscription's topic then; error is nacked or ack deadline passed; data is the payload as text, cut at 4096 bytes (truncated); next_cursor is null at the end, else pass it back as cursor (a page may hold fewer than limit). Dead letters from before 2026-12-03 are listed too, made from their copies on the dead-letter topic by a one-time backfill at server start (until it finishes for a subscription, which on a large topic can take a few minutes after a deploy): their error is reason unknown (before 2026-12-03), at_ms is null, attempts 0 and id dl:<sub>:<position> (the copy does not carry the original event's id: this one is derived from the dead letter's identity, so it is the same every time it is replayed and no published event can have it, since ids cannot contain :; position and topic are the original's).
POST /subs/{sub}/dead/{pos}/replayOne dead letter delivered again, exactly once: in one conditional commit it becomes a lease due at once (the subscription's next pull, or its webhook's next delivery, hands it out as a redelivery with its attempts counted afresh) and is no longer a dead letter. {sub, position, id, replayed: true}. Two replays, or a replay and a drop, at once: one lands, the other is 404 (gone). 409 if the message is outstanding on the subscription again.
DELETE /subs/{sub}/dead/{pos}One dead letter dropped for good (and its copy on the dead-letter topic): {sub, position, id, dropped: true}; 404 if it is gone already.
PUT /webhooks/{name} {topic, url}As Webhooks/Create.
GET /webhooks?topic=, GET / DELETE /webhooks/{name}, POST /webhooks/{name}/rotate {overlap_s?, revoke_old?}As Webhooks/List, Get, Delete, RotateSecret.
GET /webhooks/{name}/deliveries?before=&limit=, POST /webhooks/{name}/redeliver {pos}The last 100 delivery attempts (newest first; no bodies, secrets or URL paths), and one event sent again (signed, webhook-redelivery: true, 10 a minute, cursor untouched; 410 for an event below the topic's retention floor, swept or not). HTTP only.
GET / PUT /read/{topic}/thread/{event_id}Your position in one thread and its unread replies: Threads.
PUT / DELETE /reactions/{topic}/{event_id}/{emoji}, GET /reactions/{topic}?events=A person's emoji on a topic's event: below.
POST /typing/{topic}"X is typing" on a topic, ephemeral: below.
POST /publish/{topic}/{id}?reply_to=<event id>, GET /threads/{topic}/{event_id}, GET /threads/{topic}?events=Replies to a topic's event, their page and their counts: below.
GET /healthLiveness and counters.

Client events on a socket

A client on /live/{topic} publishes into that topic over the same socket with a text frame:

{"publish": {"id": "<id>", "data": "<text>"}}

It is published exactly as POST /publish/{topic}/{id} is: the token needs publish on the topic (the same scope, org or FGA writer check; the subscribe grant alone reads but does not send), data is at most 1,000,000 bytes, a notification rule's publish rate applies, and the same id again finds the first event (duplicate). Every frame is answered, in the order sent, with one of:

FrameWhen
{"ack": {"id", "pos", "duplicate"}}The event is committed; pos is its position, as POST /publish answers. Subscribers (the sender too) get it from the change stream in position order; the sender's own event frame and its ack may arrive in either order.
{"error": {"id"?, "status", "message"}}Refused, with the status the HTTP publish would answer: 400 (not a publish frame, bad id; no id when the frame couldn't be read), 401/403 (no publish grant), 413 (data too large), 429 (rule rate; for a person its message says to publish through POST /publish/{topic}/{id} or Connect Topics/Publish, which can ask for a nod, because a socket can't), 409, 503.

A refusal never closes the socket, and a client without the grant keeps reading. A frame is at most 2 MiB (past it the connection closes, 1009), or 4 KiB on a socket that sends its token as the first frame (a browser's: a bigger event goes over POST /publish); a binary frame is answered 400. Metrics count these publishes under route socket.

Threads

A reply is a normal event of the same topic, published with reply_to (POST /publish/{topic}/{id}?reply_to=<event id>, Topics/Publish's reply_to, the SDKs' replyTo / reply_to, the publish tool's reply_to). It has an id, a position and a publisher, is in the topic's history (Topics/Read and Delivered carry reply_to on a reply and nothing on any other event, so no client written before threads is affected), and reaches /live/{topic} as an ordinary frame that also has "reply_to": "<parent id>". Publishing needs the publish grant the topic needs; the parent must exist (404), be at or after the retention floor (410) and not itself be a reply (400: a thread is one level). The same id with the same data and parent is a duplicate as any publish is; with another parent it is a 409. Stored as an optional reply_to on the event (absent on every other event), and as a small thread-links record written in the same commit, which is what is indexed: events that are not replies cost nothing extra.

GET /threads/{topic}/{event_id}?cursor=&limit= pages a thread's replies oldest first, one query a page (limit 1 to 200, default 50; next_cursor is null at the end). GET /threads/{topic}?events=a,b,c answers each of up to 100 parents' replies, last_reply_pos and last_reply_ago_s in one read (one query per 30 parents), counted from the replies' records, never from a counter per parent; a parent with more replies than one query returns is paged, to 10 pages, then capped: true says the count is a lower bound. Events carry no timestamp, so the last reply's time is its age now, read from its commit version (retention's clock). A reply below the retention floor is hidden from both at once, swept or not, so a swept reply is never counted.

Read state per thread: PUT /read/{topic}/thread/{event_id} {pos} moves your position in that thread forward only, and GET of it answers the position and the thread's unread replies (at most 99, capped meaning "99+"; replies below the retention floor don't count), read from thread-links by the parent's index from your position, never a scan. The batch counts add unread and unread_capped per parent for the caller, from the replies the count already reads plus your positions in one more query per 30 parents (they are another collection, so one query cannot hold both). Topic and thread read state are independent: marking a topic read does not mark its threads, and marking a thread read does not move the topic's position; a client that wants both sends both.

A chat's main timeline without the replies: /live/{topic}?top_level=1 (SubscribeRequest.top_level on Topics/Subscribe) sends only events that aren't replies. A skipped reply still moves the stream on (on Topics/Subscribe the keepalive hello carries the position past it), so a client resuming from the last position it has neither sees the reply again nor misses an event it would show; it reads a thread with GET /threads/{topic}/{event_id}. Without the flag a stream is as before.

History takes the same flag: ReadRequest.top_level on Topics/Read (the SDKs' read(…, topLevel) / top_level=) returns only events that aren't replies. limit counts those shown, latest is the newest shown, and each keeps its own position, so the last one is where a live stream with top_level picks up.

Reactions

A reaction is one person's emoji on one event of a topic, kept beside the topic and never in its history. The path's {emoji} is percent-encoded UTF-8 (%F0%9F%91%8D) or a short name (%3Ashipit%3A). It is one emoji (a single grapheme: a base emoji with an optional variation selector and skin tone, joined by ZWJ up to five, a keycap, a flag), or a :name: of 1 to 32 of a-z 0-9 _ + -. Adding and removing are idempotent per person, event and emoji, and two adds racing leave one reaction (a conditional write on its record: exactly one call answers changed: true). The server reads counts from the reactions' records, so a page of a chat costs one query per 30 events, not one per event, and no counter is kept per event. An event takes at most 20 different emoji (a race of first reactions with different emoji can overshoot by as many as race). An event below the topic's retention floor takes and shows no reaction (the sweep, which asks retention for the floor, deletes the reactions of events it swept).

Live. A socket opened with /live/{topic}?reactions=1 also gets a frame for every change, from any server:

{"reaction": {"id": "<event id>", "emoji": "👍", "by": "<subject>", "on": true}}

on: true is a reaction added, false one removed; a client adds or subtracts one from the count it holds. The frame has no pos and is not an event: it is not stored in the topic's history, is not replayed when a socket resumes with after, and is lost if the socket lags. A client reads GET /reactions/{topic} once it is connected and follows the frames from then. Sockets that do not ask never see one. The sweep's deletes show as on: false for events no client lists.

Typing

POST /typing/{topic} with {"state": "typing"} or {"state": "stopped"} says the caller is typing on the topic, or has stopped. Who is typing is the token's subject, never a field of the request. It needs both grants: publish (only someone who may post may signal) and subscribe (only someone who may read may see), checked as those routes check them (never an agent's inbox). The answer is {topic, state}. It is ephemeral: never an event, never in the topic's history, never in read state or an unread count. One short-lived record per person per topic holds it, in a collection of its own.

Live. A socket opened with /live/{topic}?typing=1 gets a frame for every change, from any server:

{"typing": {"by": "<subject>", "on": true, "ttl_ms": 6000}}

on: true is "by is typing": show it for ttl_ms after the last such frame, and it lapses on its own. A client renews about every 3 s while the person types (a renewal is another typing). on: false is "stopped" (said, or by publishing to the topic: the person's own event ends it at once). The frame has no pos, is not an event and is not replayed when a socket resumes with after; it is lost if the socket lags. A socket opened without typing=1 never sees one, and ?reactions=1 does not bring them. The socket's access is re-checked as it lives, as for any /live socket, so a person who loses the topic stops seeing it.

Limit. The stored record is the limit, so it holds across servers: a typing within 1 s of the person's last write for the topic (any server's) is dropped silently, answered as any other, and writes nothing; a write that loses a race to another server's is dropped likewise. A person may be typing on at most 5 topics at once (live records are at most people x 5): a typing for a sixth is 429, and room comes as one stops, is stopped by publishing, or lapses. Servers count from the change stream, so the cap can be passed briefly by the stream's lag. stopped is not limited (it deletes only a record that exists), so a stop right after a typing is not lost. A lapsed record is deleted by a sweep within about 15 s, and that delete shows as on: false.

Metrics (Prometheus) are on a listener of their own, --metrics-listen, never this one: operating.md.

Webhook URLs and browser push endpoints must be public addresses: an IP-literal host on loopback, a private, link-local, shared or reserved range (or one of those inside IPv6) is refused when given (400), and a name is connected to only through its public addresses (a delivery to one that has none fails, last.detail says why). No redirects are followed. A server whose receivers are on its own machine (the proofs, the clients' prove_* scripts) runs with --allow-private-urls yes; never a shared one.

Plans

An org may have a plan (free, pro or team, crates/proto-server/src/orgs.rs PLANS), set by the site's billing (PUT /v1/orgs/{org}/plan, scope sendack:plans:write) and shown by GET /v1/orgs/{org}. An org a product site provisions (POST /v1/orgs, scope sendack:orgs:provision: a new org only, its namespace its own name) starts on free. The plan caps the org's webhooks (on its topics) and functions (the lower of the plan's and --max-functions-per-org); over it is 429. An org with no plan (one from before plans, or an operator's) has the server's limits alone; a plan this version doesn't know takes nothing new. A whole-org PUT that leaves plan out keeps it.

PlanWebhooksFunctionsAPI keysLive sockets per personHistory (days)
free552107
pro2520105030
team10050255090

The last two are what sendack.dev sells; the server doesn't yet hold an org to them (sockets are counted per server, --max-sockets-per-person, and a topic's history is its admin's retention, retention.rs).

API keys

A team's admin or owner makes API keys for their org (crates/proto-server/src/keys.rs): POST /v1/orgs/{org}/keys answers the token once (sendack_<org>_<id>_<secret>); the server keeps only the secret's SHA-256, never shows it again, and DELETE takes it away. A key is sent as a bearer token like any other and reaches only its org's topics: it publishes and subscribes under the org's prefixes, and nothing else (no admin, retention, webhooks, org or key routes; a key can't make keys). A stream on a key is cut after 5 minutes, as any token's at its expiry, so a deleted key's stream ends too. The plan caps how many an org holds (Plans: free 2, pro 10, team 25; an org with no plan 25, an unknown plan none). An agent acting for the admin needs the person's nod to make one (a key publishes with no nod of its own); the site makes them for its signed-in admin through its own client (for). No MCP tool, SDK or CLI mints them.

Every route and its auth

One row per HTTP route the server answers (crates/proto-server/src/server.rs), method and path as the router has them. A test (api_md_lists_every_route_with_its_auth) fails when a route is added, removed or renamed without this table following, or a row has no auth. "A valid token" means one that passes --harpora-issuer checking; on an open server nothing is checked. "Nod" in the auth column means the route also needs a person's approval of that exact action (below); the test also fails when that word and nod::ROUTES (crates/proto-server/src/nod.rs) disagree. The MCP endpoint (/mcp) is the console's and the agents'; it is not listed here.

RouteAuth
POST /publish/{topic}/{id}the topic's publish scope or FGA writer; on a topic with a notification rule, a person past its rate (see Limits) is held for a nod (Nod approvals) instead of 429, for exactly that event (topic, id, data); a service's token keeps the 429
POST /publish-batch/{topic}the topic's publish scope or FGA writer; on a topic with a notification rule, a person past its rate (see Limits) is held for a nod (Nod approvals) instead of 429, ONE for exactly that batch (topic and the ordered ids and data); a service's token keeps the 429
GET /live/{topic}the topic's subscribe scope or FGA reader; a browser sends the token as its first frame, or a ticket ({"ticket": "..."}, from POST /live-ticket/{topic}): one use, subscribe only
POST /live-ticket/{topic}the topic's subscribe scope or FGA reader: {ticket, expires_in}, a 60-second one-use ticket for a socket's first frame; the socket it opens cannot publish. Kept by its SHA-256 in socket-tickets
GET /presence/{topic}the topic's subscribe scope or FGA reader
GET /threads/{topic}/{event_id}the topic's subscribe scope or FGA reader: ?cursor=&limit=; one page of the event's replies, oldest first: {topic, event, replies: [{pos, id, data, reply_to, publisher?}], next_cursor} (pos null if unknown, next_cursor null at the end). 400 bad id, cursor or limit, 404 no such event, 410 the event is below the retention floor. Replies below the floor are left out, so a page can be short without being the last. Never an agent's inbox
GET /threads/{topic}as above: ?events=a,b,c, 1 to 100 event ids; {topic, events: {<id>: {replies, last_reply_pos, last_reply_ago_s, capped, unread, unread_capped}}} for the whole page in one read (one query per 30 events, and one more per 30 that have replies for your thread positions); unread is your unread replies in each thread, at most 99; an event with no replies has replies: 0 and nulls. Swept replies are not counted
POST /typing/{topic}the topic's publish scope or FGA writer and its subscribe scope or FGA reader (both: the grants publishing and subscribing need): {"state": "typing" | "stopped"}, answered {topic, state}; 400 for another state or an agent's inbox, 403 without either grant, 429 for a sixth topic. Inside the 1 s gap the call is answered the same and nothing happens. Never an event: typing
GET /reactions/{topic}the topic's subscribe scope or FGA reader: ?events=a,b,c, 1 to 100 event ids; counts per emoji and whether you reacted, for the whole page in one read (one query per 30 events): {topic, events: {<id>: {reactions: [{emoji, count, me}], capped}}}, most reacted first, an event with none []. capped: the event has more reactions than could be read, so its counts are lower bounds. Reactions of events past the retention floor are not counted. Never an agent's inbox
PUT /reactions/{topic}/{event_id}/{emoji}the topic's publish scope or FGA writer (the grant publishing needs): your reaction is added, {topic, event, emoji, reacted: true, changed}; adding it again is changed: false. 400 for an emoji that is not one emoji or a short :name: (or a bad id), 404 no such event, 410 the event is below the retention floor, 409 a new emoji on an event that already has 20 different ones
DELETE /reactions/{topic}/{event_id}/{emoji}as PUT: your reaction is removed, reacted: false; removing one that isn't there is changed: false
GET /read/{topic}/thread/{event_id}the topic's subscribe scope or FGA reader (as topic read state): your own position in the event's thread and its unread replies, {topic, event, pos, unread, capped}, counted from the thread's links from your position, at most 99, replies below the retention floor not counted. 400 bad id or an event that is a reply, 404 no such event, 410 the event is below the retention floor. Never an agent's inbox
PUT /read/{topic}/thread/{event_id}as GET. Body {"pos": "<version>.<index>"}: your position in the thread only moves forward (moved: false for an older or equal one), two writers racing end at the later; answers as GET with moved. A position past the database's head is a 400. Does not touch the topic's position, nor does marking the topic read touch this: independent
GET /read/{topic}the topic's subscribe scope or FGA reader: your own read position and unread count, {topic, pos, unread, capped} (pos null: never set; unread counts the events after pos, at most 99, capped meaning "99+"; events past the retention floor don't count; never an agent's inbox)
PUT /read/{topic}as GET. Body {"pos": "<version>.<index>"}, a position as an event came with it: your position only moves forward, so an older or equal one changes nothing (moved: false), and two writers racing end at the later; answers as GET with moved. A position past the database's head is a 400
POST /read-batchas GET, checked for each topic on its own. Body {"topics": ["…"]}, 1 to 100: {topics: [{topic, pos, unread, capped} or {topic, error, status}]} in order, so a refused topic doesn't fail the others (all refused for a missing token: 401)
GET /retention/{topic}the topic's subscribe scope or FGA reader: {topic, max_age_s, max_count} (null: no such limit; both null: kept for ever)
PUT /retention/{topic}the topic's admin: the scope sendack:topic:<topic>:admin, an admin or owner of an org covering it, FGA admin, or staff (recorded). Body {"max_age_s": 60 to 315360000, "max_count": 1 to 10000000}, either or both: history older than max_age_s, or beyond the newest max_count events, is hidden from reads and swept (kept only if both allow it; a 400 names the field). The count is found by the sweep (every 10 s for such topics), so a read can briefly return a few events beyond the newest max_count: at most N plus what arrived since the last pass. Not on the server's own topics (agent inboxes, notifications, hooks)
DELETE /retention/{topic}the topic's admin (as PUT): back to keeping history for ever
GET /healthnone
GET /substhe subscription's use scope, for each listed
PUT /subs/{sub}the subscription's use scope (a hook- name is 400), and the right to subscribe to the topic and publish to the dead-letter topic
GET /subs/{sub}the subscription's use scope (a hook- name is 400)
DELETE /subs/{sub}the subscription's use scope (a hook- name is 400)
POST /subs/{sub}/pullthe subscription's use scope (a hook- name is 400)
POST /subs/{sub}/ackthe subscription's use scope (a hook- name is 400)
POST /subs/{sub}/nackthe subscription's use scope (a hook- name is 400)
POST /subs/{sub}/seekthe subscription's use scope (a hook- name is 400)
GET /subs/{sub}/deadthe subscription's use scope (a hook- name is 400)
POST /subs/{sub}/dead/{pos}/replaythe subscription's use scope, as a seek (a hook- name is 400)
DELETE /subs/{sub}/dead/{pos}as deleting the subscription: its use scope; through an org, the one who made it or an admin or owner (a hook- name is 400)
GET /.well-known/oauth-protected-resourcenone (answers only when tokens are checked)
GET /v1/orgsany signed-in caller: their own orgs
POST /v1/orgsa product site: a machine token with sendack:orgs:provision (a person, staff included, is 403). {name, owner, plan?} makes a new customer's org (201): owner (email:<address> or sub:<subject>) its one owner, namespace and topics <name>., on plan (free unless said). An org of that name is 409 and left as it is; an overlap with another org's topics 422; a reserved name or an unknown plan 400 (Plans)
PUT /v1/orgs/{org}/plana machine token with sendack:plans:write (the site's billing) or sendack:orgs:write: {"plan"} (free, pro or team) answers {org, plan}; no org 404, an unknown plan 400
GET /v1/orgs/{org}org member (any role), or an operator (staff too: audited); answers namespace, roots and whether the caller may set the namespace (can_set_namespace)
PUT /v1/orgs/{org}an operator: a machine token with sendack:orgs:write (a person, staff included, is 403: they change an org through the member, client and prefix routes below)
GET /v1/orgs/{org}/keysan org admin or owner (a deployer 403, a stranger 404), or a product site ?for= its signed-in admin on an org it provisioned (any other org is 404 to it): the org's API keys, {keys: [{id, name, created_by, created_ms}]}, never a secret (API keys)
POST /v1/orgs/{org}/keysan org admin or owner; an agent acting for one (a token with act) needs the person's nod (org.key.create, Nod approvals); a product site's machine token with sendack:orgs:provision may make one {"for": "email:…" or "sub:…"} its signed-in admin, needing none, on an org it provisioned only (any other, an operator's or another site's, is 404 to it whoever it names). {name} answers 201 {id, name, created_by, created_ms, token}, the token shown this once; over the plan's keys 409 (API keys)
DELETE /v1/orgs/{org}/keys/{id}an org admin or owner, or a product site ?for= its admin on an org it provisioned: 204, the key stops working within seconds (the org cache); no such key 404
GET /v1/orgs/{org}/webhooksorg member (any role), or an operator
GET /v1/orgs/{org}/topicsorg member (any role), or an operator (staff too: audited); every topic under the org's prefixes that holds events (never a reserved one), by name: {topics: [{topic, events, newest: {id, publisher, version} | null}], next}. ?q= keeps names containing it, ?after= is a page's next, ?limit= 1 to 200 (default 50). events counts what retention still holds; it comes from the events-by-topic TwilightDB view, kept off the publish path
GET /v1/orgs/{org}/activityorg member (any role), or an operator (staff too: audited); the org's events per UTC day over the last ?days= (1 to 90, default 30, today included): {days: [{day, events}] (every day, oldest first), topics: [{topic, events}] (the five busiest in the window), since_ms}; with ?topic= (one the org covers, else 400) that topic's alone. From the events-by-topic-day view of each event's at_ms: events published before at_ms existed, and those retention deleted, are not counted
GET /v1/topics/{topic}/accesswhoever administers the topic: the scope sendack:topic:<topic>:admin (or a pattern covering it), an org admin or owner whose prefix covers it, FGA admin, or staff (recorded); a prefix ending . is answered from the orgs; answers publish, subscribe, administer (each a list of {who, kind: member|client|fga, via, org}), scopes and fga
GET /v1/orgs/{org}/auditthe org's owners and Nelm staff (a member is 403, a stranger 404); each record has id, who, action, tenant, target, detail (what the target alone loses, e.g. a webhook's topic and host or a rotation's mode; "" on a record made before it existed), at_ms, request_id
GET /v1/orgs/{org}/approvalsthe org's owners and Nelm staff see every ask, any other member the ones they asked, a stranger 404; newest first, ?before= (a page's next) and ?limit= (1 to 500, default 50): {approvals: [{id, org, reference, action, resource, summary, for, who, status, message, asked_ms, expires_ms, decided_ms}], next}. status is pending, approved, denied or expired; a pending ask past expires_ms reads as expired. Kept 30 days from the ask
POST /v1/orgs/{org}/approvalsany member (or staff), for their own ask: {reference, action, resource, summary, for, wait_ms} (reference the one the asker gave, 32 hex digits; wait_ms up to a day) records it as pending (201); a reference already recorded is 409; 16 pending a person and 256 an org at most (429)
PUT /v1/orgs/{org}/approvals/{reference}only its asker, once, while pending: {status: "denied" or "expired", message}; approved is 400 (it is recorded where the approval is used, not by the asker), an ended one 409, another's 404
POST /v1/topics/{topic}/approvalsas POST /v1/orgs/{org}/approvals, kept in the org whose prefix covers the topic (none: 404); for an ask about a topic's change (a webhook, a publish, a notification rule). The answer's org is where its end is then told
PUT /v1/orgs/{org}/members/{who}an org owner, and a nod (Nod approvals); an operator (a machine token with sendack:orgs:write) needs none, nor does the product site's machine (sendack:orgs:provision) on an org it provisioned (provisioned_by), keeping its members as its team's (any other org is 404 to it)
DELETE /v1/orgs/{org}/members/{who}an org owner, and a nod (Nod approvals); an operator (a machine token with sendack:orgs:write) needs none, nor does the product site's machine (sendack:orgs:provision) on an org it provisioned (provisioned_by), keeping its members as its team's (any other org is 404 to it)
PUT /v1/orgs/{org}/nod-account/{account}an org owner (or staff, or an operator), and a nod of the Nod account's owners (Nod approvals): the nod is asked of the account itself (sendack.org.link, org acct-…, class owners), no machine token skips it; 400 unless {account} is acct- and letters, digits, _ or -, 409 when another org has it; records the org's Nod account id (nod_account, shown by GET /v1/orgs/{org}), which functions act for. PUT /v1/orgs/{org} cannot set or change it
PUT /v1/orgs/{org}/clients/{client}an org admin or owner, and a nod (Nod approvals); an operator (a machine token with sendack:orgs:write) needs none
DELETE /v1/orgs/{org}/clients/{client}an org admin or owner, and a nod (Nod approvals); an operator (a machine token with sendack:orgs:write) needs none
GET /v1/orgs/{org}/namespace/{root}Nelm staff or an operator (a member is 403, a stranger 404): whether adding the root, or removing it when the org has it, would be refused, and why
PUT /v1/orgs/{org}/namespace/{root}Nelm staff, and a nod (Nod approvals), audited; an operator (a machine token with sendack:orgs:write) needs none; 400 for a reserved root, 409 for one inside or over another org's
DELETE /v1/orgs/{org}/namespace/{root}Nelm staff, and a nod, audited; an operator needs none; 409 while the org's prefixes lie inside it
PUT /v1/orgs/{org}/topics/{prefix}an org admin or owner, and a nod (Nod approvals); an operator (a machine token with sendack:orgs:write) needs none
GET /v1/orgs/{org}/topics/{prefix}an org admin or owner (what still uses topics under the prefix)
DELETE /v1/orgs/{org}/topics/{prefix}an org admin or owner, and a nod (Nod approvals); an operator (a machine token with sendack:orgs:write) needs none; 409 while webhooks, subscriptions or notification pushers use topics only it covers
GET /functions?topic=, the topic's subscribe scope or FGA reader: {functions: [{function, topic, flow, version, org, dead_letter}]}. 404 unless the server runs with --functions yes
PUT /functions/{name}{topic, flow, version?, filter?}, or prefix instead of topic: every topic under it, ending in ., those made later included, in commit order; its admin is the org's admin or owner role or a scope pattern over the whole prefix (docs/functions.md, "Prefix bindings") (filter: at most 16 {field, equals}, a dot path into the event's data and a JSON scalar; only matching events start a run, the rest are acknowledged unstarted, docs/functions.md): the topic's admin (as retention), and a nod (Nod approvals) given by the person Nod's org policy names for the org covering the topic (not necessarily the caller). Without Nod-Approval it answers 403 at once with the challenge (nothing is kept or made); the repeat of the same PUT with the approval has Sendack's machine client make the org's machine grant with it at the accounts API, and stores the binding (its grant is the grant's id). A stale, spent or wrong approval is 403 with a fresh challenge and nothing is made. Binds the topic to the Camshaft flow from the topic's end. 404 unless --functions yes; 400 for a topic outside every org or a server-owned one; 409 if the name is taken (unbind first)
GET /functions/{name}the function's topic subscribe scope or FGA reader: its binding
DELETE /functions/{name}the topic's admin, no approval needed: unbinds it and has the machine client delete its grant; if that delete fails the binding is removed anyway and the answer has grant: "left" with a note (the org's owner revokes it). Runs already started are Camshaft's
GET /functions/{name}/deadthe topic's admin: its dead letters (events Camshaft, or the org's token exchange, refused for good), each with the reason, as GET /subs/{sub}/dead lists them (which does not serve a hook's own subscription)
GET /functions/{name}/runs?topic= (the binding's, else 404): the topic's admin: the binding's last 50 starts, newest first, from its own delivery log (webhook-attempts/fn-<name>, no new collection): run id, pos, id, at_ms, outcome (started, or failed), status, a short reason, attempt, and dead when the event was dead-lettered at pos. topic must be the binding's (else 404)
POST /functions/{name}/pausethe topic's admin, nobody else to ask: events are not started while paused; they wait on the topic, the subscription untouched
POST /functions/{name}/resumethe topic's admin, never asked again for what binding approved: goes on from exactly where it stopped; the answer's retention says if events it has not started are below the topic's retention floor
POST /functions/{name}/dead/{pos}/replaythe topic's admin: one dead letter handed to the pusher again; the start is re-attempted with the same run id (`sha256(orgtopicflowposevent_id): the stored position, which Sendack assigns, is in it; Camshaft dedupes one that did start); answers therun_id`
GET /webhookssendack:webhooks:create, or an org member
PUT /webhooks/{name}sendack:webhooks:create, or an org member for hooks on the org's topics (delete, rotate and redeliver: the hook's maker, or an org admin or owner); a nod (Nod approvals) unless the URL's host is in the org's limits.webhook_hosts or the token is a service's own with the scope; the approval names the webhook, topic and URL, so one for another URL is refused
GET /webhooks/{name}sendack:webhooks:create, or an org member for hooks on the org's topics (delete, rotate and redeliver: the hook's maker, or an org admin or owner)
DELETE /webhooks/{name}sendack:webhooks:create, or an org member for hooks on the org's topics (delete, rotate and redeliver: the hook's maker, or an org admin or owner)
POST /webhooks/{name}/rotatesendack:webhooks:create (a service's own, needs no nod), or an org member for hooks on the org's topics (the hook's maker, or an org admin or owner) and a nod (Nod approvals); the approval names the mode (revoke_old, or the overlap in seconds, 0 being 24 h, at most 7 days), so one for a 24 h overlap is refused for revoke_old (Nod approvals)
GET /webhooks/{name}/deliveriessendack:webhooks:create, or an org member for hooks on the org's topics (delete, rotate and redeliver: the hook's maker, or an org admin or owner)
POST /webhooks/{name}/redeliversendack:webhooks:create, or an org member for hooks on the org's topics (delete, rotate and redeliver: the hook's maker, or an org admin or owner)
GET /notify/keynone (a public key; 404 if the server has no VAPID key)
POST /notify/subscribea token naming a person (their own subscription)
DELETE /notify/subscribea token naming a person (their own subscription)
GET /notify/rules/{topic}sendack:notify:rules or staff, and the right to read the topic
PUT /notify/rules/{topic}sendack:notify:rules (a service's own, needs no nod) or staff, and the right to read the topic, and a nod (Nod approvals)
DELETE /notify/rules/{topic}sendack:notify:rules (a service's own, needs no nod) or staff, and a nod (Nod approvals)
POST /notify/email-dueCamshaft's signed callback (internal; no token)
GET /notify/preferencesa token naming a person (their own)
PUT /notify/preferencesa token naming a person (their own)
POST /sendack.v1.Topics/Publishthe topic's publish scope or FGA writer; on a topic with a notification rule, a person past its rate (see Limits) is held for a nod (Nod approvals) instead of 429, for exactly that event (topic, id, data); a service's token keeps the 429
POST /sendack.v1.Topics/PublishBatchas POST /publish-batch/{topic}: the topic's publish scope or FGA writer; a person past the rate on a topic with a notification rule is held for a nod for exactly that batch, the same approval as the REST route's (either serves either, once); a service's token keeps the 429
POST /sendack.v1.Topics/Readthe topic's subscribe scope or FGA reader
POST /sendack.v1.Live/Subscribethe topic's subscribe scope or FGA reader
POST /sendack.v1.Subscriptions/Createthe subscription's use scope (a hook- name is 400), and the rights as for PUT /subs/{sub}
POST /sendack.v1.Subscriptions/Pullthe subscription's use scope (a hook- name is 400)
POST /sendack.v1.Subscriptions/Ackthe subscription's use scope (a hook- name is 400)
POST /sendack.v1.Subscriptions/Nackthe subscription's use scope (a hook- name is 400)
POST /sendack.v1.Subscriptions/Seekthe subscription's use scope (a hook- name is 400)
POST /sendack.v1.Subscriptions/Listthe subscription's use scope (a hook- name is 400)
POST /sendack.v1.Subscriptions/Getthe subscription's use scope (a hook- name is 400)
POST /sendack.v1.Subscriptions/Deletethe subscription's use scope (a hook- name is 400)
POST /sendack.v1.Webhooks/Createsendack:webhooks:create, or an org member for hooks on the org's topics (delete, rotate and redeliver: the hook's maker, or an org admin or owner); a nod (Nod approvals) unless the URL's host is in the org's limits.webhook_hosts or the token is a service's own with the scope; the approval names the webhook, topic and URL, so one for another URL is refused
POST /sendack.v1.Webhooks/Listsendack:webhooks:create, or an org member for hooks on the org's topics (delete, rotate and redeliver: the hook's maker, or an org admin or owner)
POST /sendack.v1.Webhooks/Getsendack:webhooks:create, or an org member for hooks on the org's topics (delete, rotate and redeliver: the hook's maker, or an org admin or owner)
POST /sendack.v1.Webhooks/Deletesendack:webhooks:create, or an org member for hooks on the org's topics (delete, rotate and redeliver: the hook's maker, or an org admin or owner)
POST /sendack.v1.Webhooks/RotateSecretsendack:webhooks:create (a service's own, needs no nod), or an org member for hooks on the org's topics (the hook's maker, or an org admin or owner) and a nod (Nod approvals)
POST /sendack.v1.Notify/Keynone (a public key; 404 if the server has no VAPID key)
POST /sendack.v1.Notify/Subscribea token naming a person
POST /sendack.v1.Notify/Unsubscribea token naming a person
POST /sendack.v1.Notify/GetPreferencesa token naming a person
POST /sendack.v1.Notify/SetPreferencesa token naming a person
POST /sendack.v1.Notify/PutRulesendack:notify:rules (a service's own, needs no nod) or staff, and a nod (Nod approvals)
POST /sendack.v1.Notify/DeleteRulesendack:notify:rules (a service's own, needs no nod) or staff, and a nod (Nod approvals)

Org namespaces

An org's topic prefixes lie inside its namespace (namespace, a list of roots on the org), which only an operator sets, through the whole-org replace. An org's admins (and staff, through the nod) add prefixes only inside it: outside is 403. An org with no namespace (stored before they existed) has its current prefixes as its namespace, so it can narrow and never widen. No org may own or cover a reserved name: agent., notify., nod., hook-, sendack- (422 on a whole-org set, 400 on a prefix). Two orgs' namespaces and prefixes never overlap.

Staff and operators set the namespace one root at a time: PUT and DELETE /v1/orgs/{org}/namespace/{root} (the whole-org replace stays the operator's). A root is checked as a prefix is: 400 with the reason for a reserved name or one over it, 409 when it overlaps another org's roots or prefixes, and 409 on a removal naming the prefixes still inside the root. An org with no namespace has its prefixes as one (below); the first root added keeps them as roots, so adding widens it. GET /v1/orgs/{org} shows namespace (as set), roots (as it applies) and can_set_namespace; GET /v1/orgs/{org}/namespace/{root} says, without changing anything, whether the change would be refused. Staff changes are in the org's audit.

Nod approvals

A route marked "nod" above performs an action a person must approve (docs/agents.md, "Whose nod"). The API itself enforces it, for every caller (the MCP server, the console, a script): one layer on the whole router, driven by the table in nod.rs, so no handler and no second path to one can skip it.

  1. The call without approval is refused 403 with WWW-Authenticate: Bearer error="insufficient_authorization", nod="<Nod's issuer>", authorization_details="<base64url JSON>" naming the exact action (action, method, resource, a summary a person reads). Connect routes answer the same as a Connect error.
  2. The caller asks Nod for it (CIBA bc-authorize with those authorization_details, login_hint sub:<the caller>); a person approves on their own device (lunaor's own Nod accounts auto-approve).
  3. The caller repeats the call with Nod's approval token in Nod-Approval. It passes only if the token is from --nod-issuer (default: --harpora-issuer) for this API, is for the same action, method and resource, was given to the caller themselves, and has not been used: it is good for one call (the used ones are kept in the database, so every server sees them).

Actions: org.topic.add / org.topic.remove (sendack:org:<org>/topics/<prefix>), org.client.add / org.client.remove (.../clients/<client>), org.member.set (.../members/<who>/<role>: an approval is for the role it names) / org.member.remove (.../members/<who>), sendack.org.link (sendack:org:<org>, asked of the Nod account named in the path: org acct-…, class owners) and webhook.rotate (sendack:webhook:<name>/rotate/<mode>@<id>: an approval is for the webhook that exists, <id> a digest of its topic, URL and maker, so one deleted and made again under its name needs a new approval), webhook.create (sendack:webhook:<name>/create/<topic>/<url>: an approval is for the target it names), topic.publish (sendack:topic:<topic>/publish/<id>/sha256-<hex of the data>: for exactly that event), topic.publish.batch (sendack:topic:<topic>/publish-batch/<n>/sha256-<hex>, the digest over the ordered list of each item's id, data digest and, for a reply, its reply_to (a line is id digest or id digest parent, so a batch with no replies has the digest it always had): for exactly that batch, so another topic, a reordered batch or a changed, added or dropped item, or another parent, needs its own approval) and notify.rule.set / notify.rule.clear (sendack:notify:rules/<topic>; the REST and the Connect routes name the same action, so one approval serves either). function.bind (camshaft:flow:<flow>: for exactly that flow) is the one whose approval is not the caller's and is not for Sendack's audience: its challenge names the org covering the topic, the class access and Sendack's machine client (authorization_details org, class, client, with the accounts API as locations), so Nod's org policy picks the approver (an admin or owner of the org, who may start its flows in Camshaft, or the binder where the org's policy approves its own). The gate does not hold it: the handler answers the challenge, checks the repeat's approval is for exactly this flow, org and machine, and has the machine client present it to the accounts API, which verifies and spends it (once). One nod per binding, never per event; DELETE /functions/{name} needs none.

Two of these are asked only outside the caller's standing rules: webhook.create when the URL's host is not in the org's limits.webhook_hosts (inside it, or with a service's own scope, the call is free), and topic.publish / topic.publish.batch only when a person's publish on a topic with a notification rule is past its rate (the publisher's bucket can't take the event, or all the batch's events; a machine token is not asked and keeps the 429). An approved publish or batch takes nothing from the bucket, and an approved batch is published whole, once. A batch is for one topic (its path), so it is one approval, never one per topic. Its items are checked first: an invalid one is the 400 (413 for too much data) with no challenge, and a batch bigger than the rule's burst is still the 400 "at most N events in one batch" (no approval lifts it: send smaller ones). POST /publish-batch/{topic} and Connect Topics/PublishBatch name the same action and resource, so one approval serves either, once. A socket's client events are not covered: a nod is a Nod-Approval header on a request and a frame has none, so a person past the rate on a socket gets the 429 with the way to proceed in its message (publish through POST /publish/{topic}/{id}, or Connect Topics/Publish, or POST /publish-batch/{topic} / Topics/PublishBatch, which can ask for approval).

Who needs none: a machine token (a client-credentials token, not a person's) holding the route's scope (sendack:orgs:write, sendack:webhooks:create, sendack:notify:rules), which is the operator's or a service's own standing grant with no person to ask. A person is always asked, whatever scopes the token carries: org roles and lunaor staff included. A server that checks tokens but has no Nod to check against refuses these calls (503); one that checks no tokens (open) has no one to ask.

Verifying webhooks

A delivery the receiver doesn't answer 2xx is retried, in order, after 1 s doubling to 60 s. A 429 or 503 with Retry-After: <seconds> sets the wait instead (at least 1 s, at most 60 s: a longer answer is asked again after 60 s; an HTTP date is not read and the doubling applies).

Every delivery carries webhook-id (msg_<webhook>_<pos>, the same on a retry or redelivery: dedupe on it), webhook-timestamp (Unix seconds, fresh on each attempt) and webhook-signature: v1,<base64> entries separated by spaces, each the HMAC-SHA256, keyed by the secret's bytes (whsec_<base64>), of "<webhook-id>.<webhook-timestamp>." followed by the body. While a rotated secret overlaps there are two entries (new, then old). A redelivery also has webhook-redelivery: true. The body is {topic, pos, id, data, publisher}.

Verify the raw body: the bytes as they arrived, never JSON you parsed and re-serialised. Re-serialising changes spaces, key order and escapes, and the signature then fails. Each SDK's verify_webhook(secret_or_secrets, headers, raw_body, tolerance = 5 min) checks the headers, the timestamp (older or newer than the tolerance is refused: a replay) and the signature (constant time, against every secret you pass: pass the new and the old during a rotation), and returns the parsed event or raises why: missing_header, bad_signature, too_old, too_new. Answer 2xx only after it verified.

// Rust (sendack_client): headers is any iterator of (name, value); axum: body is the extractor's raw Bytes
let event = sendack_client::verify_webhook(&[&new_secret, &old_secret], headers, &body, WEBHOOK_TOLERANCE)?;
println!("{} {}", event["topic"], event["id"]); // Err(WebhookError::{MissingHeader, BadSignature, TooOld, TooNew})
// TypeScript (Express: express.raw({ type: "application/json" }) so req.body is the raw Buffer)
import { verifyWebhook, WebhookVerificationError } from "@sendack/client";
try {
  const event = await verifyWebhook([newSecret, oldSecret], req.headers, req.body); // toleranceS defaults to 300
  res.sendStatus(204);
} catch (e) {
  if (e instanceof WebhookVerificationError) return res.status(400).send(e.kind); // missing_header, bad_signature, too_old, too_new
  throw e;
}
# Python (Flask: request.get_data() is the raw body, not request.json)
from sendack import verify_webhook, WebhookVerificationError
try:
    event = verify_webhook([new_secret, old_secret], request.headers, request.get_data())  # tolerance=300
except WebhookVerificationError as e:
    return e.kind, 400  # missing_header, bad_signature, too_old, too_new

sdk/fixtures/webhook-verify.json holds deliveries signed by the server's own signing code (generated by a test in crates/proto-server/src/webhooks.rs); all three SDKs verify the same file.

Notifications (docs/step3-notifications.md)

A notification is an event on the person's own topic notify.<sub>; their devices follow it.

RouteDoes
GET /notify/keyThe Web Push applicationServerKey.
POST /notify/subscribe {endpoint, keys: {p256dh, auth}, skip_when_live?}A browser's push subscription for the token's person (at most 20 browsers a person: 429 past that). skip_when_live: quiet while the person's app follows notify.<sub> live.
PUT / GET /notify/preferences {push, quiet: {from, to, tz}, email: {to, delay_s}}Push off; quiet hours in their time zone (only urgency: high passes); email after a delay if unread.
DELETE /notify/subscribe {endpoint}That browser stops getting pushes. Only the token's person's own (another's is 404, as if it never existed); on an open server, person says whose.
GET /notify/rules/{topic}The topic's rule: {topic, enabled, recipients, channels: {push, email}}, channels being what this server is configured to carry notifications by (VAPID key, Camshaft); same auth as PUT (scope sendack:notify:rules or staff, and reading the topic).
PUT /notify/rules/{topic}Each event on the topic notifies its readers (Harpora's ListUsers) or those of the event's to who may read the topic (FGA; on an open server, whoever it names), never its from.
DELETE /notify/rules/{topic}The rule stops (scope sendack:notify:rules); 404 if there's none.
POST /notify/email-dueCamshaft's signed callback (internal).

A notification's JSON may carry collapse (one push per burst), urgency and ttl. Publishing <id>.read on the same topic marks it read: its push is withdrawn and no email goes.

Agent messages

Every agent message (agentd's routes, served by the adapter) is also an event on agent.<from> and agent.<to>: id the message id, data a sendack.v1.AgentMessage (crates/adapter/proto/sendack/v1/agentmsg.proto); when it's read, <id>.read carries it again with read_us/read_by. A person reads their agent's topic with FGA reader on topic:agent.<username> (Hollowtree writes it at sign-in).