Aggregators
An aggregator is a platform that fronts many operators (its sub-operators). To the RGS you are one operator: one operator id, one key pair per environment, one wallet ingress URL. What is different is that each launch and each wallet call belongs to one of your sub-operators, and you have to keep that straight.
The one fact that shapes the integration
Wallet calls do not name the sub-operator. They carry your x-operator, a signature and the token you chose at launch. So the sub-operator is found by token: remember token -> sub-operator when you launch, and look it up when a wallet call arrives.
launch(sub-operator A, player u1) -> you store token T -> A brand: "brand-a" goes to the RGS
wallet call {token: T, ...} -> you look up T -> A hand the call to A's wallet adapter
What you send at launch
| Field | Use |
|---|---|
brand | the sub-operator's brand/site id, registered for it in the RuneCode back office: 1 to 40 characters of A-Z a-z 0-9 _ -. A brand that is not registered for you is refused with 400 ERR_BAD. Selects the brand-level release, bet levels and branding |
country | the player's country, when the sub-operators span jurisdictions. An operator enabled for more than one jurisdiction profile must send country on every launch, or have a complete brand-to-profile map, or the launch is refused with 400 ERR_JUR |
metadata | up to 2 KiB, echoed in webhooks and round lookups. Put your own sub-operator id in it |
token | unique across all your sub-operators. A UUID per launch does this |
user must be stable per player within a sub-operator. Two sub-operators may both have a player 1001: make user unique across your platform (for example casino-a:1001) if the RGS-side reports should tell them apart.
Registering sub-operators and their brands is a back-office step done with us at onboarding (see Availability: the back office is not built yet, so today this is configuration we do with you).
The SDK helpers
TypeScript (@runecode/operator-sdk/aggregator); the other languages follow (see below).
import { AggregatorClient, WalletRouter, MemorySessionStore } from "@runecode/operator-sdk/aggregator";
const sessions = new MemorySessionStore(); // tests only: use a shared, durable store in production
const agg = new AggregatorClient({
baseUrl, operatorId: "acme-agg", privateKeyPem, fullRequestSigning: true, sessions,
subOperators: [{ id: "casino-a", brand: "brand-a", country: "PE" }, { id: "casino-b", brand: "brand-b" }],
});
const { url, token } = await agg.launch("casino-a", { product: "runecode", publisher: "wizards", game: "royal-tiger-v2",
user: "casino-a:1001", currency: "USD" });
const router = new WalletRouter({
operatorSlug: "acme-agg", rgsPublicKeys: [currentKey, standbyKey], sessions,
walletFor: (subOperatorId) => adapters[subOperatorId], // your adapter per sub-operator, or one that forwards over HTTP
});
// in your HTTP server, for POST /v1/balance|debit|credit|rollback and GET /health:
const { status, body } = await router.handle(req.method, req.path, rawBody, req.headers);
AggregatorClient.launch sets brand, defaults country, adds metadata.subOperator (it cannot be overridden by the caller's metadata), generates a token when you give none and records it before calling the RGS. It retains the routing record on every error: a timeout or rejected retry cannot prove no session was accepted. It refuses a token bound to a different sub-operator, player or currency; identical reservations preserve the original creation time. Supply a stable token and Idempotency-Key when you need to retry a launch.
Cleanup is an explicit lifecycle operation after proving that no accepted session, open round or owed settlement uses the record. Do not automatically delete on a 4xx, transport failure or timeout. Shared stores must implement the insert-or-compare atomically, without overwriting existing bindings. Catalogue and lookups are group-wide, so they are on agg.rgs (a plain OperatorClient).
WalletRouter.handle verifies the signature on the raw bytes before parsing or touching your store, checks the slug, parses, looks up the token, and calls your adapter. It answers:
| Situation | Answer | Why |
|---|---|---|
| bad signature or slug | 401 ERR_ATE | as for any operator |
| malformed body or no token | 400 ERR_BAD | terminal, the call is wrong |
| token not in your store | 400 ERR_IS | terminal: the RGS stops. Make sure your store really has every token before you answer this |
| no adapter for that sub-operator | 500 ERR_GE | your misconfiguration: stay retryable, nothing is lost while you fix it |
your adapter throws anything other than a WalletError | 500 ERR_GE, no detail | the RGS retries; internals never leave |
your adapter throws a WalletError | its status and code | e.g. ERR_IPB, ERR_BC |
What stays your job
- The session store. It must be shared by every instance and durable, and a record must stay until every round of that session is closed: the RGS retries settlement forever, and a win is owed even days later. Answering
ERR_ISbecause a record was evicted makes the RGS give up on that call. - Idempotency and fencing, per sub-operator. The rules in Implementing the wallet apply unchanged. Key your books by
(sub-operator, rgs, round)and by the RGS's ids. The router does not make a wallet idempotent. - Forwarding. If a sub-operator's money lives in its own system, your adapter calls it and must answer
5xxunless it can prove the money is durably correct. Do not turn a sub-operator's timeout into a2xx. - Money rules per sub-operator: each one has its own currencies and limits, and the currency on every wallet money object must equal the session currency.
Reconciliation and billing
We bill the aggregator, with a breakdown per sub-operator (by brand). The round and transaction lookups work for the whole group; use the metadata.subOperator you sent, or your own token -> sub-operator records, to split them for each of your sub-operators. For structured logging and AWS CloudWatch setup per aggregator, see Observability and CloudWatch logging.
Other languages
The helper exists in all seven SDKs with the same behaviour. The Rust crate has no HTTP client and no JSON dependency, so it gives you prepare_launch (builds the launch body and token) and a WalletRouter that takes raw bytes and returns a status and a JSON string. For any other language, do the same three things by hand: send brand, store token -> sub-operator before you launch, and route wallet calls by token after verifying the signature.