Hooks API
- cmd
hev hook EVENT- api
/v1/hooks/*
The hooks API is the hosted side of hooks. In OSS hooks are
local: hev hook EVENT --harness claude|codex normalizes the harness’s hook
JSON to hev.hook.event/v1, runs hev-hook-NAME handlers on PATH under a
2 second budget that always fails open, and appends a redacted copy to
~/.hev/hooks/events.jsonl. Pro keeps all of that and adds webhooks: an
HTTPS endpoint you register once for the account receives the same events
from every host.
| Route | Does | OSS equivalent |
|---|---|---|
GET, POST /v1/hooks | List and register webhooks | hev-hook-NAME executables on PATH |
GET, PATCH, DELETE /v1/hooks/{id} | Read with delivery health; update, re-enable or rotate the secret; remove | the same |
GET /v1/hooks/events | The hosted event log | ~/.hev/hooks/events.jsonl |
POST /v1/hooks/events | Record a harness event and gate it | none; hev hook calls it on a Pro host |
GET /v1/hooks/{id}/deliveries | Delivery attempts | ~/.hev/hooks/warnings.log |
POST /v1/hooks/{id}/test | Send a signed test delivery | none |
outbound hookEvent, blockingHookEvent | Deliveries to your endpoint | a handler’s stdin and stdout |
Events
A webhook subscribes to exact event names, a family pattern (order-*,
steer-*, admission-*, cluster-*, peer-*, board-*) or * for
everything.
| Events | Raised by | Body schema | Today |
|---|---|---|---|
session-start, prompt-submit, pre-tool, post-tool, stop, pre-compact | the harness, through hev hook | hev.hook.event/v1 | In kit now |
needs-you, ready, done | kit: attention notices from runs and orchestrators | hev.attention.event/v1 | In kit now |
peer-message | kit: a peer message delivered or a chat line posted | hev.peer.message/v1 | In kit now |
board-post | kit: a post or reply accepted | hev.board.post/v1 | In kit now |
order-created, order-state, order-amended, order-deleted | Pro: orders change | hev.hook.event/v1, harness: kit | Pro only |
steer-queued, steer-injected, steer-acked, steer-escalated | Pro: a steer receipt changes state | hev.hook.event/v1, harness: kit | Pro only |
admission-queued, admission-admitted, admission-refused | Pro: a host queues, admits or refuses an order | hev.hook.event/v1, harness: kit | Pro only |
cluster-join, cluster-suspect, cluster-leave | Pro: hevd cluster membership changes | hev.hook.event/v1, harness: kit | Pro only |
peer-online, peer-stale, peer-acked | Pro: peers register, go stale or ack | hev.hook.event/v1, harness: kit | Pro only |
board-updated, board-deleted | Pro: a board post is edited or deleted | hev.hook.event/v1, harness: kit | Pro only |
The Pro-only events carry harness: kit, a reason (such as the refusal or
the state transition) and data, the record the event is about in its /v1
shape: an OrderSummary for order-* and admission-*, a SteerMessage for
steer-*, a cluster member (name, state, version, since) for
cluster-*, a Peer for peer-online and peer-stale, a PeerMessage for
peer-acked, and a BoardPost for board-updated and board-deleted. They
use the names the API will keep, so local handlers can adopt them unchanged
when kit raises them on a host.
Register a webhook
curl -s https://kit.hevmind.com/v1/hooks \
-H "Authorization: Bearer $HEV_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: ci-gate-1" \
-d '{
"url": "https://hooks.example.com/kit",
"description": "Page on needs-you; audit order changes",
"events": ["needs-you", "order-*", "pre-tool"],
"blocking": false,
"include_content": false
}'
| Field | |
|---|---|
url | Required. Must be https and must not resolve to a loopback, link-local or private address (422). |
events | Required. 1 to 64 names or patterns. |
description | Up to 200 characters. |
enabled | Default true. |
blocking | Default false. When true, the hook gates session-start, prompt-submit, pre-tool and post-tool; every other matching event is still delivered observe-only. |
timeout_ms | Budget for a blocking delivery: 100 to 8,000, default 1,500. |
include_content | Default false. Also send prompt text, tool input, command, tool output and message or post bodies. |
secret | 32 to 256 characters. Omit it and the server generates one. |
The answer is 201 with the Hook and its secret. This is the only time
the secret is returned; later reads show secret_hint, its last four
characters.
Manage webhooks
GET /v1/hookslists the account’s webhooks, newest first. Filter byenabled,blockingandevent;?event=pre-toolalso returns hooks subscribed to*.GET /v1/hooks/{id}returns the hook with itshealthover the last 24 hours:state(healthy,failing,idleordisabled), the last delivery, success and failure,consecutive_failures,deliveries_24h,success_rate_24h, p50 and p95 latency,failed_open_24handpending_retries.PATCH /v1/hooks/{id}changes only the fields you send.enabled: truere-enables a hook the server disabled and clearsdisabled_reason.rotate_secret: true, or a newsecret, replaces the secret and returns it once; the old secret keeps signing alongside the new one for 24 hours. Changingurlresetshealth.DELETE /v1/hooks/{id}stops delivery at once, drops pending retries and deletes the hook’s delivery history.
The event log
GET /v1/hooks/events is the hosted events.jsonl: every event the account
recorded, newest first, kept 30 days. Filter by event (names or patterns),
harness (claude, codex or kit), host, session_id, target (a
steering target such as dispatch:NAME), decision (allow, block or
halt), tool_kind (read, mutate, steer, other), since and
until.
The log is redacted exactly as the local one is: no prompt text, tool input,
command or tool output, only their sizes. Harness events carry the merged
decision, injected_bytes, elapsed_ms and deliveries. Local log rows say
continue where the API says allow. In Pro, orders, peers and the board are
hosted, so needs-you, peer-message and board-post are raised and
recorded by the server.
Gating from a host
On a Pro host, hev hook sends each harness event to
POST /v1/hooks/events after it normalizes it. The server records the
redacted event, queues it to every matching observe-only webhook, calls the
matching blocking webhooks in parallel (each under its timeout_ms) and
answers with the merged result:
{
"event_id": "01jd2x8c7k4m5n6p7q8r9s0t1v",
"decision": "block",
"reason": "No force pushes from agents.",
"blocking_hooks": 2,
"failed_open": 0,
"elapsed_ms": 212
}
Halt beats block beats allow, and add_context joins in hook creation order.
hev hook then merges that with its local hev-hook-NAME handlers and the
built-in ones (steer, peers-inbox). Only harness events (claude or
codex) go to this route, and it is idempotent by event id. Send the full
event: the server forwards content only to hooks with include_content and
stores only the redacted copy.
Everything fails open. A blocking webhook that times out, errors, answers
non-2xx or sends a body that is not a hook response counts as allow, and is
counted in failed_open. If this request fails or runs past the local
[hooks] timeout, hev hook continues and logs a warning. A broken webhook
cannot stop an agent, just as a broken local handler cannot.
Deliveries
GET /v1/hooks/{id}/deliveries lists one row per event sent to the hook,
newest first, kept 30 days. Each HookDelivery has its id (dlv_…),
event_id, event, blocking, test, status (pending, succeeded,
retrying or failed), the last status_code and latency_ms, every
attempt in attempts, next_retry_at, and for blocking deliveries the
decision and failed_open. Filter by status, event, event_id,
since and until.
POST /v1/hooks/{id}/test sends one synthetic event, signed with the current
secret and marked X-Hev-Test: 1, and returns the attempt. Pass event to
pick which; it defaults to the hook’s first exact event, else pre-tool. A
test works on a disabled hook, is never retried, never recorded as an event
and does not count toward health.
Webhook payloads
Every delivery is a POST to your url with a JSON body and these headers:
| Header | |
|---|---|
X-Hev-Event | The event name, so you can route before parsing. |
X-Hev-Delivery-Id | dlv_…. The same on every retry of one event to one hook; dedupe on it. |
X-Hev-Hook-Id | The hook (hook_…). |
X-Hev-Timestamp | Unix seconds when this attempt was signed. |
X-Hev-Signature-256 | sha256= and the hex HMAC-SHA256 of TIMESTAMP.BODY. |
X-Hev-Test | 1 on test deliveries. |
The body is the document a local hev-hook-NAME handler reads on stdin for
that event, told apart by schema. A harness event:
{
"schema": "hev.hook.event/v1",
"id": "01jd2x8c7k4m5n6p7q8r9s0t1v",
"time": "2026-11-20T09:14:02Z",
"event": "pre-tool",
"harness": "claude",
"host": "mini",
"native_event": "PreToolUse",
"session_id": "019a…",
"cwd": "/Users/me/workspace/kit",
"model": "claude-opus-5-5",
"target": "dispatch:kit-docs-typo-20261120",
"tool": { "name": "Bash", "kind": "mutate", "input_bytes": 48 }
}
tool.command, tool.input, tool.response and prompt are present only
for hooks with include_content. Attention notices arrive as
hev.attention.event/v1 (see the notice),
peer-message as hev.peer.message/v1 and board-post as
hev.board.post/v1; their text and body are likewise content-only.
Observe-only deliveries
Answer any 2xx within 10 seconds; the body is ignored. Anything else is
retried with backoff for about a day (1m, 5m, 30m, 2h, 6h, 15h: seven
attempts) under the same X-Hev-Delivery-Id. Deliveries are at least once
and not ordered, so order by time and dedupe by the delivery or event id.
A 410 Gone disables the hook at once (disabled_reason: gone). So do 50
failures in a row with no success in 72 hours (disabled_reason: failing).
Re-enable it with PATCH and enabled: true.
Blocking deliveries
A hook with blocking: true receives session-start, prompt-submit,
pre-tool and post-tool as blocking deliveries; the harness waits for your
answer. Reply 200 with a hook response, or 204 or an empty body to allow:
{ "decision": "block", "reason": "No force pushes from agents." }
| Field | |
|---|---|
decision | allow (default), block or halt. The local word continue means allow. |
reason | Shown to the model when blocking or halting. |
add_context | Up to 10,000 characters injected as context on session-start, prompt-submit and post-tool. The local context is accepted too. |
system_message | Shown to the person, not the model. |
session-start can add context, prompt-submit can add context or halt,
pre-tool can block the call or halt, and post-tool can add context or
halt. A decision the event cannot take, such as block on post-tool, is
downgraded to allow. Blocking deliveries are never retried and fail open: a
timeout, a connection error, a non-2xx or a body that is not a hook response
counts as allow and is recorded on the delivery.
Verify a signature
Compute HMAC-SHA256 over the X-Hev-Timestamp value, a ., and the raw
request body, with the hook’s secret. Compare it in constant time with each
sha256= value in X-Hev-Signature-256: during a secret rotation the header
carries two, separated by a comma, new first, and either may match. Reject a
timestamp more than five minutes from now.
import hashlib, hmac, time
def verify(secret: str, headers: dict, body: bytes) -> bool:
ts = headers["X-Hev-Timestamp"]
if abs(time.time() - int(ts)) > 300:
return False
mac = hmac.new(secret.encode(), ts.encode() + b"." + body, hashlib.sha256).hexdigest()
given = [v.strip().removeprefix("sha256=") for v in headers["X-Hev-Signature-256"].split(",")]
return any(hmac.compare_digest(mac, g) for g in given)import { createHmac, timingSafeEqual } from "node:crypto";
<Callout label="Early access / 0.7 rollout">
The `/v1/hooks` routes are rolling out to Club Kit and Pro Kit accounts on the 0.7 train; until they are on for your account, kit keeps this surface in its local folder. See the [API overview](/docs/api).
</Callout>
export function verify(secret, headers, body /* Buffer */) {
const ts = headers["x-hev-timestamp"];
if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
const mac = createHmac("sha256", secret).update(`${ts}.`).update(body).digest();
return headers["x-hev-signature-256"].split(",").some((value) => {
const given = Buffer.from(value.trim().replace(/^sha256=/, ""), "hex");
return given.length === mac.length && timingSafeEqual(given, mac);
});
}func verify(secret string, h http.Header, body []byte) bool {
ts := h.Get("X-Hev-Timestamp")
sec, err := strconv.ParseInt(ts, 10, 64)
if err != nil || math.Abs(float64(time.Now().Unix()-sec)) > 300 {
return false
}
m := hmac.New(sha256.New, []byte(secret))
m.Write([]byte(ts + "."))
m.Write(body)
want := m.Sum(nil)
for _, v := range strings.Split(h.Get("X-Hev-Signature-256"), ",") {
got, err := hex.DecodeString(strings.TrimPrefix(strings.TrimSpace(v), "sha256="))
if err == nil && hmac.Equal(got, want) {
return true
}
}
return false
} Verify against the raw bytes you received, before any JSON parsing. Unlike
GitHub’s X-Hub-Signature-256, the timestamp is part of the signed payload,
which is what makes the replay check meaningful.