HTTP API

This page describes hookinlet's HTTP surface. It has three parts: ingest (webhooks come in), the read API (agents read them back), and operations. Agents can make the same reads as MCP tools. openapi.json describes the HTTP API in OpenAPI 3.1. It covers the requests, responses, and schemas below, and the admin API. Tests check it against the server in both directions. They call every operation. Every response it lists must actually occur and match. They also generate requests from its schemas, and the server must accept or refuse each one as the file says. Setting up inboxes, retention, and backups is in administration.

All error responses are JSON:

{"error": {"code": "not_found", "message": "not found"}}

Every response carries an X-Request-Id header. If the request sent a well-formed X-Request-Id (up to 64 characters from A-Z a-z 0-9 - _ .), the server echoes it. Otherwise the server generates one.

Read API#

Agents read an inbox's messages over plain HTTP. Every endpoint is GET (or HEAD) and returns JSON. Two kinds are the exception: /raw, and the two that keep a named reader's position (PUT and DELETE). The examples write $BASE for the server's address (export BASE=http://localhost:8080) and $TOKEN for an agent token.

GET /v1/inboxes/{slug}                       the inbox's metadata
GET /v1/inboxes/{slug}/messages              a page of messages
GET /v1/inboxes/{slug}/messages/{seq}        one message
GET /v1/inboxes/{slug}/messages/{seq}/raw    the stored bytes, as received unless the message is `modified`
GET /v1/inboxes/{slug}/readers               named readers and how far behind each is

Authentication#

Send Authorization: Bearer <token>. Two kinds of token work:

An agent token may have an expires_at (see Administration). From that moment, the server refuses it with the same 401 as a token that does not exist.

The server does not accept tokens in URLs, because URLs end up in logs.

Two responses are deliberately alike:

A disabled inbox stops accepting deliveries but stays readable, so agents can drain what it holds.

Inbox metadata#

{
  "slug": "stripe-prod",
  "name": "Stripe (production)",
  "verifier": "stripe",
  "message_count": 1240,
  "oldest_seq": 1,
  "latest_seq": 1240,
  "epoch": "9f2c41d37b7e4b0c8f4a9d1e5a6b3c20"
}

An hmac inbox also has signature_headers. These are the names of the stored headers that carry the signature (for example ["X-Signature"]), because each hmac inbox sets its own header. It holds names only, never values. The other verifiers do not have it, because the sender fixes their header.

message_count is exact. After retention has removed old messages, oldest_seq is the first one still stored. An empty inbox has zeros. The metadata never includes anything secret.

epoch identifies one life of the inbox's sequence numbers. See Epochs and gaps.

Messages#

{
  "messages": [
    {
      "seq": 1234,
      "inbox": "stripe-prod",
      "received_at": "2026-03-01T12:00:00.123456Z",
      "method": "POST",
      "path": "",
      "query": "",
      "headers": {"Content-Type": ["application/json"]},
      "content_type": "application/json",
      "size": 812,
      "verified": true,
      "verifier": "stripe",
      "verify_error": null,
      "delivery_id": "evt_1NXWPnCo6bFb1KQto6C8OWvE",
      "event_type": "invoice.paid",
      "source_ip": "203.0.113.7",
      "body": {"id": "evt_1NXWPnCo6bFb1KQto6C8OWvE", "type": "invoice.paid"}
    }
  ],
  "next": "/v1/inboxes/stripe-prod/messages?after=1234&epoch=…&limit=50",
  "latest_seq": 1240
}
Field Meaning
seq The message's per-inbox sequence number, starting at 1. This is the cursor.
received_at When the message was committed. UTC, always six fractional digits, so it sorts as text. Never earlier than the previous message's.
path, query The part of the ingest URL after the inbox key, and its query string.
headers The request headers as received, minus Authorization, Cookie, Proxy-Authorization, and the inbox's shared-token header.
size The body's size in bytes. Always present, even for a summary.
verified true only if the inbox's verifier checked something (a signature or a shared token) and it passed. A delivery to an inbox whose verifier is none is false. Treat unverified content as untrusted input.
verify_error Why verification failed, for unverified messages; otherwise null.
modified Present, and true, only when the stored body is not what the sender sent: the server's embedder replaced it before storing, to redact it, say (see extending). The signature covered the original bytes and cannot be checked against this body, though verified still says the delivery verified. Absent for every message stored as received, which is the default.
delivery_id, event_type Taken from the sender, but only for verified messages. null when absent. See verifying deliveries for which are signed and which are only labels.
source_ip The sender's address; null if unknown.

The body#

Exactly one of these fields is present, chosen by what the body is:

Field When
body The body is valid UTF-8 and valid JSON and nested no deeper than 64 levels and holds only what common parsers accept (see below). It appears as JSON, not as a string containing JSON.
body_text It is valid UTF-8 but not JSON (or is JSON that is not embedded, see below). This includes the empty body ("") and form-encoded data.
body_base64 It is not valid UTF-8. Base64 decodes to the exact original bytes.

A client that needs the original bytes of a JSON body exactly as sent should use /raw. One example is a client that checks a signature itself. body is the same JSON, but not necessarily the same text. Do not use /raw this way for a message that is modified.

The nesting limit exists because the sender controls the body. JSON nested thousands of levels deep is valid, but common parsers fail on it. Python's json module raises RecursionError at roughly 1,000 levels. One such body embedded in a page would make every page containing it unreadable, and a polling agent would be stuck on it for good. So hookinlet delivers deeper bodies as text instead. The same goes for these cases:

All of these are valid JSON. Some common parser refuses each one (Python rejects integers over 4,300 digits, Go refuses 1e400), and the sender controls all of them. These bodies come as body_text, exactly as sent.

With fields=summary, none of the three is present.

Listing messages#

GET /v1/inboxes/{slug}/messages takes these parameters. All are optional.

Parameter Meaning
after=<seq> Messages with a larger seq, oldest first. after=0 starts from the beginning. This is the polling pattern.
before=<seq> Messages with a smaller seq, newest first.
(neither) The newest messages, newest first.
limit=<n> Page size. Default 50; values above 500 are treated as 500.
type=<event type> Only these event types. Repeat it to allow several.
since=<time>, until=<time> received_at at or after since and before until. RFC 3339, such as 2026-03-01T12:00:00Z.
verified=true|false Only verified, or only unverified, messages.
delivery_id=<id> The message with this delivery id.
fields=summary Leave out the body fields.
epoch=<epoch> The epoch your cursor came from. If it is not the inbox's current one the request is a 409. next links carry it.

You cannot combine after and before. Filters combine with AND, except repeated type, which is OR.

Parameters are checked strictly. An unknown or repeated parameter, a malformed value, or a malformed query string (?after=5;&limit=2, ?after=%zz) gets a 400. A typo or a mangled cursor cannot quietly return the default page.

Paging#

Every page ends with a next link. It is a relative URL that keeps your filters and moves the cursor. Follow it until it is null.

Cursors are safe. A message can never appear behind a cursor you have already passed. So following next visits every message exactly once, in order, even while new ones arrive.

A page may hold fewer than limit messages, and that does not mean the end. The server also caps a page at 16 MiB as sent (a page always holds at least one message). That counts everything about each message after JSON escaping, including headers. So a few large messages end a page early, and so do many messages with large headers, even with fields=summary. Always go by next.

latest_seq is the inbox's newest sequence number as of the same moment as the page. So latest_seq - seq tells you how far behind you are.

Epochs and gaps#

A cursor is a sequence number, and a sequence number only means something within one life of an inbox. If you delete an inbox and make it again under the same slug, it starts at 1 again. So does a server restored from a backup, which may have accepted different messages since the backup was taken. A cursor from before would quietly skip or repeat messages. So each inbox has an epoch: an opaque string that changes in those cases and never otherwise. Pages, messages, stream events and next links all carry it. epoch= on a request says which epoch your cursor came from. If it is not the current one, the answer is 409 epoch_changed. Then read epoch from the inbox and start again from the cursor you want (after=0 for everything stored). A next link already includes epoch=, so following links protects you without extra work.

gap is true on a page read with after= when retention removed messages after your cursor before you got to them. What follows does not continue where you left off. after=0 never reports a gap. If you must see every message, size retention for how long your reader may be away. A stream announces a gap the same way (event: gap) whenever it arises, including while the stream is running.

One message#

GET /v1/inboxes/{slug}/messages/{seq} returns a single message object, with its full body. A number that cannot be a sequence number (0, -1, 01, abc) gets a 404, like one that does not exist.

Both this and .../raw take epoch=. If a seq belongs to an earlier life of the inbox, the server refuses it with 409. Without epoch=, it would answer with whatever message has that number now. A message carries its epoch, but raw bytes do not, so pin a raw fetch with the parameter.

Raw bytes#

GET /v1/inboxes/{slug}/messages/{seq}/raw returns the stored bytes exactly. The Content-Type is exactly the one the sender used, or application/octet-stream if it sent none. These are the bytes that were received, unless the message is modified. A server whose embedder redacts or rewrites bodies before storing them keeps and returns the rewritten bytes. It does not keep the original. Use /raw when you need the original bytes, for instance to hand them to a tool that checks a signature. Skip messages that say modified, because their signature does not match what is stored.

Whoever sent the webhook chooses the content and its type. So the server never serves them as something a browser would run. The response also carries X-Content-Type-Options: nosniff, Content-Security-Policy: default-src 'none'; sandbox, and Content-Disposition: attachment. These do not change the bytes or the Content-Type.

Following an inbox live (SSE)#

GET /v1/inboxes/{slug}/stream

Instead of polling, an agent can hold a connection open and get each message as it arrives. The messages come as Server-Sent Events (SSE). The stream takes the same Authorization: Bearer header as the rest of the read API, and the same 401 and 404 rules. Browsers' EventSource cannot send headers. Use a client that can, such as curl -N or fetch with a streaming body.

curl -N -H "Authorization: Bearer $TOKEN" "$BASE/v1/inboxes/stripe-prod/stream"
retry: 3000

id: 1241
event: message
data: {"seq":1241,"inbox":"stripe-prod", ...the same JSON as the REST API...}

: ping

id: 1242
event: message
data: {...}

Where a stream starts#

How Meaning
Last-Event-ID: <seq> header Resume after that message. A client that reconnects sends this automatically.
?after=<seq> Start after that message, replaying anything newer. after=0 replays everything.
(neither) From now: only messages that arrive after the stream opens.

Last-Event-ID wins over after. A reconnecting client reuses its original URL, and the header says how far it actually got. After a catch-up, the stream keeps following live. A client that reconnects with the id of the last event it saw receives every later message exactly once, with no gaps and no repeats. This holds even if messages arrived while it was disconnected.

type= (repeatable) and verified=true|false filter the stream exactly as they do for the list endpoint. epoch= names the epoch your cursor came from, as for the list endpoint. If a stream is opened with another epoch, the server refuses it with 409 before anything is sent. (A browser reconnects to the URL it first used. So a client that opened the stream with epoch= is protected on every reconnect.) Other parameters get a 400.

What can end a stream#

Limits#

At most HOOKINLET_MAX_STREAMS streams (1000 by default) are open at once. At most HOOKINLET_MAX_STREAMS_PER_INBOX can be open for any one inbox (half of MAX_STREAMS by default), so one inbox cannot use up every slot. More get 503 with Retry-After. A stream holds a connection and little else: about 50 KiB of memory. We measured 500 idle streams at about 22 MiB on top of the server's own 10 MiB on Linux. A stream that is catching up reads pages of up to 256 KiB. So a slow client replaying large messages holds at most that much more.

If a client starts after a position the inbox has not reached yet, the stream does not fail. It opens with a comment saying so, and waits.

Streams do not count against the limit on concurrent page reads, except for the moments they spend reading. So an open stream never keeps an ordinary read out.

On platforms that scale to zero: an open stream is an open connection. Some platforms count that as activity and keep the instance awake. An agent that wants an instance to sleep when idle should poll /messages instead.

Named readers and lag#

A reader normally keeps its own cursor, and the server remembers nothing about it. A reader can also give itself a name and tell the server how far it has got. Then anyone who can read the inbox can see how far behind it is. This is opt-in. The server records a position only when a reader acknowledges one (PUT, below). A read, a page, or a stream never records one. Reads stay reads. A position the server holds is information for people and dashboards. It does not change what after= returns, and a reader still resumes from the cursor it keeps.

PUT    /v1/inboxes/{slug}/readers/{name}    acknowledge a position (creates the reader)
GET    /v1/inboxes/{slug}/readers           every named reader, with its lag
DELETE /v1/inboxes/{slug}/readers/{name}    forget a reader (204)

All three take the same credential as the other read operations: an agent token for the inbox, or the admin token. A name is 1 to 64 characters of ASCII letters, digits, ., _ and -, starting with a letter or digit. A name that does not fit gets a 404, like any path parameter that cannot name anything. These endpoints take no query parameters. A reader= on an existing endpoint gets a 400, like any unknown parameter.

Acknowledge with the seq and the epoch it came from:

curl -fsS -X PUT -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
  -d '{"seq": 41, "epoch": "'"$EPOCH"'"}' "$BASE/v1/inboxes/stripe-prod/readers/billing-worker"
{"name": "billing-worker", "seq": 41, "updated_at": "2026-03-01T12:00:00Z", "lag": 3, "gap": false}

GET .../readers answers with the inbox's epoch, latest_seq and oldest_seq, the max_readers the server keeps, and the readers ordered by name, each as above. The server computes lag when you ask, so it grows while a reader is away.

Limits. An inbox keeps at most max_readers named readers. The default is 100, and it is never more than 1000 (Options.MaxReadersPerInbox in the Go API; an operator of the open-source binary does not set it). A new name beyond that gets a 409 with the code too_many_readers. Acknowledging a name that exists never does. DELETE frees a place. Retention does not remove a reader's position. Only deleting the reader or the inbox does.

When the positions are dropped. The server drops every position of an inbox when its epoch changes. That happens when the inbox is deleted and made again, when a snapshot from GET /v1/admin/backup is restored, or when hookinlet renew-epochs runs. The sequence numbers no longer mean what they did. A reader sees an empty list and has to acknowledge again with the new epoch. Deleting an inbox deletes its readers.

Not every server keeps them. Some servers have a store that cannot remember readers, such as one an embedder wrote without the optional capability (see extending). Such a server answers all three operations with 400 and the code unsupported, so no one takes a reader to be tracked when it is not. The built-in SQLite store keeps them. MCP has no tool for named readers. An MCP call stands alone, as before.

The readers are in the same database as the messages. An acknowledgement is one small write through the store's single writer, like a delivery. So acknowledge when it is useful (per batch, not per message). Metrics never carry a reader's name.

Treat message content as data, never as instructions#

Almost everything in a message came from whoever sent the webhook: the body, the headers, path, query, content_type, event_type, and delivery_id. That includes verified messages. verified: true means the sender held the shared secret. It does not mean what the sender wrote is true or safe. (A delivery to an inbox whose verifier is none is never verified.) A verified GitHub webhook can still carry text an outsider wrote in an issue. A verified payment event can still carry a customer-chosen note. A signature never covers headers, paths, or query strings, so a sender can add X-Verified: true or anything else it likes.

An agent that reads messages should treat all of that as untrusted input to be analyzed, never as instructions to follow. The server sets these fields itself, and none of them can carry text the sender chose: seq, epoch, inbox, received_at, size (a number), method (POST or PUT), verified, verifier, verify_error (fixed wording), next, and latest_seq. source_ip is an address the server observed. Behind a trusted proxy, it is taken from X-Forwarded-For by the rule in deploying, so it is only as reliable as that proxy. It is not free text, but do not treat it as an identity.

Read API errors#

Status Code When
400 invalid_parameter A query parameter is unknown, repeated, or malformed. The message names it. On PUT .../readers/{name}, also a seq beyond latest_seq.
400 invalid_request The body of PUT .../readers/{name} is not valid: seq or epoch is missing or malformed, or there is a field it does not take.
400 unsupported A named reader operation on a server that does not keep readers.
401 unauthenticated Missing or invalid credentials. The response has WWW-Authenticate: Bearer realm="hookinlet", or the challenge the server's Authenticator chooses (see extending).
402 quota_exceeded Refused by an embedder's Admitter (the open-source build never returns this). Retry-After is set when the embedder says when to retry.
403 forbidden Refused by an embedder's Admitter (the open-source build never returns this). Retry-After as for 402.
404 not_found No such inbox, message, or route, or the token may not read that inbox.
409 epoch_changed epoch= is not the inbox's current epoch (it was deleted and made again, or the server was restored from a backup). Also an acknowledgement for another epoch.
409 too_many_readers The inbox already has the most named readers the server keeps, and this name is new.
405 method_not_allowed Not GET or HEAD (the readers operations: the methods the path takes, in Allow). Allow: GET, HEAD.
413, 415 payload_too_large, unsupported_media_type The body of PUT .../readers/{name} is over 1 KiB, or is not application/json.
429 rate_limited Refused by an embedder's Admitter (the open-source build never returns this). Retry-After as for 402.
500 internal A server-side problem. Details are in the server log.
503 overloaded Too many reads are in progress (16 by default) and none finished within 10 seconds, or (for a stream) too many streams are open. Retry-After is set. Authentication happens first, so unauthenticated traffic cannot cause this.

Every read response carries Cache-Control: no-store and X-Content-Type-Options: nosniff.

Ingest#

POST /in/{key}
PUT  /in/{key}
POST /in/{key}/{path...}
PUT  /in/{key}/{path...}

{key} is the inbox's ingest key (ingest_key in the admin API). By default it is a random string, not the slug. The server stores anything after it with the message as path, and stores the query string as query. Ingest needs no authentication beyond the inbox's verifier.

Responses#

Status Code When
200 The delivery was stored (or was a duplicate of one already stored). Body: {"seq": 42}. A Slack url_verification handshake also gets 200, with the challenge as plain text.
400 bad_request The request body could not be read, including when it does not arrive within 60 seconds.
401 verification_failed The signature or token did not verify and the inbox's on_verify_fail is reject. The message is always webhook verification failed; the specific reason is in the server log.
402 quota_exceeded Refused by an embedder's hook (the open-source build never returns this). Retry-After is set when the hook says when to retry.
403 forbidden Refused by an embedder's hook. Retry-After as for 402.
404 not_found No such inbox, or the inbox is disabled. The two are indistinguishable.
405 method_not_allowed Any method other than POST and PUT. The Allow header is POST, PUT. Checked before the inbox is looked up.
413 payload_too_large The body exceeds the inbox's max_body_bytes (default 1 MiB, at most 10 MiB).
429 rate_limited Not stored, and not acknowledged. Either an embedder's hook refused it (with Retry-After when the hook says when to retry), or the inbox already holds as many unverified messages as it may (HOOKINLET_MAX_UNVERIFIED, 1000 by default; see Unverified messages) and this delivery is unverified. A verified delivery is never refused for that reason.
431 The request line and headers exceed 64 KiB (plus a few KiB of slack). Headers are stored with the message and returned to agents, so their size is bounded at the door.
500 internal A server-side problem, including a misconfigured verifier. Details are in the server log, never in the response.
503 overloaded or storage_full Not stored, and not acknowledged: retry after Retry-After. overloaded: too many deliveries are being received at once for the server's memory (HOOKINLET_INGEST_MEMORY_BUDGET, 128 MiB by default; counted as bodies arrive, and the delivery is refused as soon as its bytes would go over). storage_full: there is no room to store it. Webhook senders retry a 503, which is what is wanted.

seq is the message's per-inbox sequence number, starting at 1. A duplicate delivery returns the seq of the message that is already stored.

Guarantees#

Operations#

GET /healthz   200 {"status": "ok"}     the process is up
GET /readyz    200 {"status": "ready"}  the store is reachable, there is room, some of a sample of secrets open
               503 {"error": {"code": "not_ready", ...}} it is not, or it is draining or shutting down

Neither needs authentication. Use /healthz to check that the process is alive and /readyz to check that it is ready for traffic.

From docs/api.md at v0.11.1. Markdown · View on GitHub · Back to top