Server

Webhooks

Signed webhook events for verdicts, actions, reviews, bans, appeals and guard signals, and how to verify them in Node, Python, Go and C#.

valkyr-server can push every decision to your own services: a moderation bot, a chat channel relay or your game backend. Add one [[webhooks]] entry per receiver:

TOMLTOML
[[webhooks]]name = "moderation"url = "http://127.0.0.1:9000/valkyr"secret = "a long random string"events = ["verdict", "action", "review.closed", "ban.created", "appeal.filed"]min_action = "review"format = "json"   # or "discord"

Only http:// URLs are delivered natively. For an https receiver, run a small local relay or reverse proxy and point url at it.

Event types

verdict, action, review.closed, kick, warning, ban.created, ban.activated, ban.updated, ban.revoked, ban.expired, wave.executed, appeal.filed, appeal.decided and guard.signal. Each has a JSON Schema in docs/schemas/ and an entry in the API reference.

A verdict event looks like this:

verdict.jsonJSON
{  "id": "evt_0123456789abcdef0123456789abcdef",  "type": "verdict",  "created_ms": 1764849600000,  "data": {    "match_id": "m1",    "verdict": {      "player": 7,      "server_time_ms": 1764849600000,      "flags": [        {          "rule": "movement.speed",          "category": "movement",          "player": 7,          "server_time_ms": 1030,          "severity": 0.8,          "summary": "moved at 20.0 m/s, limit 7.5 m/s",          "evidence": [            {              "name": "horizontal_speed",              "observed": 20,              "limit": 7.5,              "unit": "m/s"            }          ]        }      ],      "probability": 0.9712,      "trust": 2.88,      "action": "kick",      "reason": "kick: probability 0.971 from 2 rule(s) (view.pitch, movement.speed)"    }  }}

Headers

HeaderValue
Valkyr-EventThe event type.
Valkyr-DeliveryA unique id; retries reuse it, so you can drop duplicates.
Valkyr-Signaturet=<unix ms>,v1=<hex HMAC-SHA256(secret, "<t>.<raw body>")>

Verify the signature

Compute the HMAC over the timestamp, a dot and the raw body bytes, compare in constant time, and reject timestamps more than five minutes away from your clock. Verify before parsing the JSON.

import { createHmac, timingSafeEqual } from 'node:crypto'; // header: the Valkyr-Signature value. body: the raw request bytes (Buffer).export function verifyValkyr(secret, header, body, toleranceMs = 5 * 60 * 1000) {  const parts = header.split(',').map((p) => p.trim().split('='));  const t = parts.find(([k]) => k === 't')?.[1];  const sigs = parts.filter(([k]) => k === 'v1').map(([, v]) => v);  if (!t || !/^\d+$/.test(t) || sigs.length === 0) return false;  if (Math.abs(Date.now() - Number(t)) > toleranceMs) return false;  const expected = createHmac('sha256', secret).update(`${t}.`).update(body).digest();  return sigs.some((hex) => {    const got = Buffer.from(hex, 'hex');    return got.length === expected.length && timingSafeEqual(got, expected);  });}

The Node and Python versions were run against signatures from valkyr-server; the Go and C# versions follow the same steps but were not compiled here.

You can also check a captured delivery from the command line:

ShellShell
valkyr verify-webhook --secret "$SECRET" --signature "t=...,v1=..." --body-file body.json

Retries

Network errors, 5xx and 429 answers are retried with exponential backoff: retry_base_ms, then twice that, up to max_attempts. Other 4xx answers are final. Answer quickly with a 2xx and do slow work afterwards.

Edit this page on GitHub