Kroos Developers
Kroos Developers › Events & integrations

Webhooks

Receive signed events for usage thresholds, spend limits, budgets, abuse, key misuse, credits, invoices and handoffs.

Register an endpoint#

bash
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 events to receive all of them.
  • The response includes a signing secret (whsec_…) shown once.
  • Remove with DELETE /api/tenant/webhooks/:id.

Events#

EventWhen
usage.threshold_reachedUsage crosses 50, 75 or 90% of an allowance
spend.limit_reachedAn organization or workspace spend cap is hit
ratelimit.sustainedA workspace stays at its rate limit
enduser.budget_exhaustedAn end user used their budget
abuse.detectedInjection attempts, extraction or bot behavior
enforcement.state_changedA visitor is watched, throttled, blocked or restored
key.foreign_originYour publishable key was used from an origin you didn't allow
key.leak_suspectedA secret key was used from a new network
key.rotatedA key was rotated
credits.low_balancePrepaid credits are running low
invoice.createdAn invoice was created (invoiced plans)
handoff.requestedA visitor asked for a person
handoff.sla_breachedA handoff missed its response-time target

Payload#

json
{
  "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.

jsNode.js
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);
}
pythonPython
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 2xx within 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.

Last updated 2026-12-03