Webhooks

Custom seen stores must implement the atomic runOnce/run_once inbox operation. Separate reads and writes do not prevent concurrent duplicate effects. See Runtime safety and migration for the transaction, recovery and external-effect requirements. The memory implementation is for local tests only.

The RGS can notify your system of events (a round finished, a wallet leg confirmed, a catalogue change, a key rotation). The RGS does not deliver webhooks yet (see Availability): until it does, use the round and transaction lookups. The receiving side below is ready, so your endpoint can be built and tested now against the shared vectors.

What arrives

POST {your webhook URL} with a JSON body and these headers:

HeaderMeaning
x-signatureEd25519 over the raw body, base64, made with the RGS webhook key (a different key from the wallet key)
X-RuneCode-Eventthe event type, the same as type in the body
X-RuneCode-Deliveryunique per attempt
{ "id": "0190a1b2-c3d4-7e5f-8a6b-7c8d9e0f1a2b", "type": "round.finished", "createdAt": "2026-11-04T10:00:00Z",
  "operator": "acme", "data": { "round": 42, "status": "closed", "bet": "1.00", "payout": "2.50", "currency": "USD" } }

id stays the same across retries: deduplicate by it. Delivery is at-least-once, unordered across rounds, ordered within a round. Answer 2xx to accept; anything else, or no answer within 5 seconds, is retried with backoff (10 s, 1 m, 5 m, 30 m, then hourly) for 72 hours, after which the delivery is dead-lettered and can be re-delivered from the back office. A failing endpoint never pauses play.

The receiver helper

The same behaviour in all seven SDKs (TypeScript @runecode/operator-sdk/webhooks, Python runecode_operator.webhooks, and the equivalents elsewhere). Give it the raw body and the headers; send back the status and body it returns.

import { WebhookReceiver, MemorySeenStore } from "@runecode/operator-sdk/webhooks";

const receiver = new WebhookReceiver({
  operatorSlug: "acme",
  rgsWebhookPublicKeys: [currentWebhookKey, standbyWebhookKey],
  seen: new MemorySeenStore(),                       // tests only: use a shared, durable store in production
  handlers: { "round.finished": async (event) => { await recordRound(event.data); } },
});
// in your HTTP server, for POST /rgs-webhook:
const { status, body } = await receiver.handle(rawBody, req.headers);
SituationAnswer
missing or bad signature (checked on the raw bytes, before parsing)401 ERR_ATE
body is not JSON, or the envelope is incomplete, or data is not an object400 ERR_BAD
operator is not yours, or X-RuneCode-Event disagrees with type400 ERR_BAD
id already handled200, your handler is not called again
type with no handler200: new event types are added without a version change, so ignore what you do not know
your handler throws500 ERR_GE, no detail; the id is not marked as seen, so the retry runs it again

What stays your job