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:
[[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., kick, warning, ban., ban., ban., ban., ban., wave., appeal.filed, appeal. and guard.. Each has a JSON Schema in docs/ and an entry in the API reference.
A verdict event looks like this:
{ "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
| Header | Value |
|---|---|
Valkyr-Event | The event type. |
Valkyr-Delivery | A unique id; retries reuse it, so you can drop duplicates. |
Valkyr-Signature | t=<unix ms>, |
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); });}import hashlibimport hmacimport time def verify_valkyr(secret: bytes, header: str, body: bytes, tolerance_ms: int = 300_000) -> bool: """header: the Valkyr-Signature value. body: the raw request bytes.""" fields = [p.strip().split("=", 1) for p in header.split(",") if "=" in p] t = next((v for k, v in fields if k == "t"), None) sigs = [v for k, v in fields if k == "v1"] if t is None or not t.isdigit() or not sigs: return False if abs(int(time.time() * 1000) - int(t)) > tolerance_ms: return False expected = hmac.new(secret, t.encode() + b"." + body, hashlib.sha256).hexdigest() return any(hmac.compare_digest(expected, s) for s in sigs)package valkyrhook import ( "crypto/hmac" "crypto/sha256" "encoding/hex" "strconv" "strings" "time") // Verify checks a Valkyr-Signature header against the raw request body.func Verify(secret []byte, header string, body []byte, tolerance time.Duration) bool { var ts string var sigs []string for _, part := range strings.Split(header, ",") { k, v, ok := strings.Cut(strings.TrimSpace(part), "=") if !ok { continue } switch k { case "t": ts = v case "v1": sigs = append(sigs, v) } } t, err := strconv.ParseInt(ts, 10, 64) if err != nil || len(sigs) == 0 { return false } if d := time.Since(time.UnixMilli(t)); d > tolerance || d < -tolerance { return false } mac := hmac.New(sha256.New, secret) mac.Write([]byte(ts + ".")) mac.Write(body) expected := mac.Sum(nil) for _, s := range sigs { got, err := hex.DecodeString(s) if err == nil && hmac.Equal(got, expected) { return true } } return false}using System;using System.Linq;using System.Security.Cryptography;using System.Text; public static class ValkyrWebhook{ // header: the Valkyr-Signature value. body: the raw request bytes. public static bool Verify(byte[] secret, string header, byte[] body, long toleranceMs = 300_000) { var fields = header.Split(',') .Select(p => p.Trim().Split(new[] { '=' }, 2)) .Where(p => p.Length == 2) .ToList(); var t = fields.FirstOrDefault(p => p[0] == "t")?[1]; var sigs = fields.Where(p => p[0] == "v1").Select(p => p[1]).ToList(); if (t == null || !long.TryParse(t, out var ts) || sigs.Count == 0) return false; if (Math.Abs(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - ts) > toleranceMs) return false; using var hmac = new HMACSHA256(secret); var expected = hmac.ComputeHash(Encoding.ASCII.GetBytes(t + ".").Concat(body).ToArray()); foreach (var s in sigs) { if (s.Length != 64) continue; byte[] got; try { got = Convert.FromHexString(s); } catch (FormatException) { continue; } if (CryptographicOperations.FixedTimeEquals(got, expected)) return true; } return false; }}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:
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_, then twice that, up to max_. Other 4xx answers are final. Answer quickly with a 2xx and do slow work afterwards.