Register an endpoint#
curl -s -X POST https://kroos.ai/api/tenant/webhooks \
-H "authorization: Bearer kroos_sk_..." -H "content-type: application/json" \
-d '{"url":"https://example.com/hooks/kroos","events":["handoff.requested","credits.low_balance"]}'- URLs must be
https://and publicly reachable (private networks are refused). - Omit
eventsto receive all of them. - The response includes a signing secret (
whsec_…) shown once. - Remove with
DELETE /api/tenant/webhooks/:id.
Events#
| Event | When |
|---|---|
usage.threshold_reached | Usage crosses 50, 75 or 90% of an allowance |
spend.limit_reached | An organization or workspace spend cap is hit |
ratelimit.sustained | A workspace stays at its rate limit |
enduser.budget_exhausted | An end user used their budget |
abuse.detected | Injection attempts, extraction or bot behavior |
enforcement.state_changed | A visitor is watched, throttled, blocked or restored |
key.foreign_origin | Your publishable key was used from an origin you didn't allow |
key.leak_suspected | A secret key was used from a new network |
key.rotated | A key was rotated |
credits.low_balance | Prepaid credits are running low |
invoice.created | An invoice was created (invoiced plans) |
handoff.requested | A visitor asked for a person |
handoff.sla_breached | A handoff missed its response-time target |
Payload#
{
"id": "whd_…",
"type": "handoff.requested",
"created": "2026-11-30T18:04:11.000Z",
"tenant": "ten_…",
"data": { "...": "event-specific fields" }
}Headers: Kroos-Signature: t=<unix seconds>,v1=<hex> and Kroos-Event-Id: <id>.
Verify the signature#
The signature is HMAC-SHA256 of "<t>.<raw body>" with your signing secret. Reject requests older than five minutes and compare in constant time.
import { createHmac, timingSafeEqual } from "node:crypto";
export function verifyKroos(rawBody, header, secret, toleranceSec = 300) {
const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
const t = Number(parts.t);
if (!t || Math.abs(Date.now() / 1000 - t) > toleranceSec) return false;
const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest();
const got = Buffer.from(parts.v1 ?? "", "hex");
return got.length === expected.length && timingSafeEqual(got, expected);
}import hashlib, hmac, time
def verify_kroos(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool:
parts = dict(p.split("=", 1) for p in header.split(","))
t = int(parts.get("t", "0"))
if not t or abs(time.time() - t) > tolerance:
return False
expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, parts.get("v1", ""))Use the raw request body; re-serialized JSON won't match.
Delivery and retries#
- Respond with any
2xxwithin a few seconds. Do slow work after responding. - Failed deliveries retry with exponential backoff (1, 2, 4… minutes, capped at 6 hours) for up to 8 attempts.
- Deliveries can arrive more than once or out of order: deduplicate on
Kroos-Event-Id.