Webhooks
Instead of asking Kuma over and over, let Kuma tell you: it POSTs each event to your URL as it happens.
Events
| Event | When | Needs |
|---|---|---|
case.created | A moderation case was opened (a warning, mute, kick, ban, AutoMod action…). | cases:read |
case.updated | A case's status or reason changed (appealed, resolved, reason edited). | cases:read |
member.level_up | A member reached a new level. | levels:read |
member.coins_changed | Someone's coins were changed by staff (!coins give, take or set, or the dashboard) or through the API. Not sent for coins earned by chatting. | economy:read |
member.erased | Someone asked Kuma to erase their data. Delete what you hold about them. Always sent. | always sent |
ping | Sent when you press "Send test". | always sent |
Like a key, a webhook only gets events the person who added it could read, and stops getting them if they lose that permission or the server switches the feature off.
Set one up
- On the dashboard, under Developer API → Add a webhook, enter an
https://URL and tick the events. - Copy the signing secret (
whsec_…). Kuma shows it once. - Press Send test: your endpoint gets a
ping, and the log shows whether it arrived.
What arrives
POST /kuma HTTP/1.1
Content-Type: application/json
Kuma-Event-Id: evt_5b2c…
Kuma-Event-Type: case.created
Kuma-Delivery-Id: dlv_81fe…
Kuma-Delivery-Attempt: 1
Kuma-Signature: t=1795354971,v1=4f0c…
{
"id": "evt_5b2c…",
"type": "case.created",
"api_version": "v1",
"created_at": "2026-11-22T14:22:51.000Z",
"server_id": "01HQ8…",
"data": { "case": { "id": 412, "action": "warn", "reason": "Spam", "user": { … }, "moderator": { … }, … } }
}Check it's really from Kuma
Kuma-Signature is t=<unix seconds>,v1=<signature>. The signature is the hex HMAC-SHA256 of <t>.<raw body> using your signing secret. Check it over the raw body, before parsing the JSON, and refuse anything more than five minutes old.
import crypto from "node:crypto";
import express from "express";
function fromKuma(secret, header, rawBody) {
const parts = Object.fromEntries(String(header).split(",").map((p) => p.split("=")));
if (!parts.t || !parts.v1 || Math.abs(Date.now() / 1000 - Number(parts.t)) > 300) return false;
const want = crypto.createHmac("sha256", secret).update(`${parts.t}.${rawBody}`).digest();
const got = Buffer.from(parts.v1, "hex");
return got.length === want.length && crypto.timingSafeEqual(got, want);
}
const seen = new Set(); // use your database in real life
const app = express();
app.post("/kuma", express.raw({ type: "application/json" }), (req, res) => {
if (!fromKuma(process.env.KUMA_WEBHOOK_SECRET, req.get("Kuma-Signature"), req.body)) {
return res.sendStatus(401);
}
const event = JSON.parse(req.body);
res.sendStatus(200); // answer first...
if (seen.has(event.id)) return; // ...ignore repeats...
seen.add(event.id);
handle(event); // ...then do the work
});import hashlib, hmac, json, os, time
from flask import Flask, request, abort
app = Flask(__name__)
SECRET = os.environ["KUMA_WEBHOOK_SECRET"].encode()
def from_kuma(header, raw):
parts = dict(p.split("=", 1) for p in (header or "").split(",") if "=" in p)
if "t" not in parts or "v1" not in parts or abs(time.time() - int(parts["t"])) > 300:
return False
want = hmac.new(SECRET, f"{parts['t']}.".encode() + raw, hashlib.sha256).hexdigest()
return hmac.compare_digest(want, parts["v1"])
@app.post("/kuma")
def kuma():
if not from_kuma(request.headers.get("Kuma-Signature"), request.get_data()):
abort(401)
event = json.loads(request.get_data())
# ... handle event, skipping ids you've seen ...
return "", 200Delivery rules
- Answer quickly. Any 2xx within 10 seconds counts as delivered. Do slow work after answering.
- Retries. Anything else is tried again after 1 minute, 5 minutes, 30 minutes, 2 hours, 8 hours, 24 hours, then given up. The dashboard keeps 7 days of deliveries and can resend any of them.
- Duplicates and order. An event can arrive more than once, and out of order. Skip
ids you've already handled; order bycreated_at. - No redirects. Kuma doesn't follow them: point the webhook at the final URL.
- Switched off. If you answer
410 Gone, or every delivery fails for three days, Kuma stops sending until someone switches the webhook back on.