Guides
Wallet integration
In real mode, your Wallet holds the player’s money and we call it. You implement five endpoints, verify our signature and apply every transaction exactly once per transaction ID. This page explains how money must behave; the Wallet API reference lists every field.
The money model
The integration is seamless: we never keep a balance of our own. Your Wallet is the only source of truth for the player’s balance, and every movement of money is a WalletTransaction we send you. Demo GameSessions never call your Wallet.
| Endpoint | Operation | We call it |
|---|---|---|
POST /v1/wallet/balance | Report the current balance | When the game asks for the player’s balance, for example when it starts |
POST /v1/wallet/debits | Take a stake | Once per Round, when it starts |
POST /v1/wallet/credits | Pay out, or close a Round with zero | Once per Round, when its Outcome is recorded |
POST /v1/wallet/reversals | Cancel a Debit in full | Only to cancel a Round |
GET /v1/wallet/transactions/{transaction_id} | Report what happened to a transaction | When we didn’t get a usable answer |
Requirements for your endpoint
- HTTPS on port 443 with a certificate from a public certificate authority, valid for the host name. We use TLS 1.2 or 1.3 and HTTP/1.1.
- A public DNS name that resolves only to public addresses. We refuse private, loopback and other special-use ranges, and IP addresses in place of a name.
- An optional base path: we append the fixed paths to your base URL, for example
https://wallet.casino.example.com/v1/wallet/debits, orhttps://api.casino.example.com/provider/lucky8/v1/wallet/debitswith the base path/provider/lucky8. Each segment of a base path is non-empty, isn’t.or.., and uses only ASCII letters, digits,-,.,_and~; no query, fragment or percent-encoding. - No redirects: we don’t follow them.
- Answer fast. Our current limit is 5 seconds per attempt, which also covers our own preparation, and connecting plus the TLS handshake must finish within 2 seconds.
- Response bodies up to 64 KiB, not compressed: no
Content-Encoding, or exactlyidentity. We sendAccept-Encoding: identity. - Exactly one
Content-Type, with no parameters:application/jsonfor 200,application/problem+jsonfor errors. Many frameworks add; charset=utf-8by default; we treat such an answer as unusable, so turn that off. - On every response:
Cache-Control: no-store,X-Content-Type-Options: nosniffand anX-Request-Idthat’s a UUID v4. Echoing ours works.
Verify our requests
Every call carries the Wallet access token you issued to us and an Ed25519 HTTP Message Signature made with our private key. Accept a request only when both verify. The profile mirrors the Operator API profile, with its own tag.
| Header | Value |
|---|---|
Authorization | Bearer and the Wallet access token you issued. |
Content-Type | application/json on POST. |
Content-Digest | sha-256=:…: of the exact body bytes, on POST. |
Signature-Input | sig1 with the covered components below and the parameters created, expires, nonce, keyid, alg="ed25519" and tag="provider-wallet-api-v1", in that order. |
Signature | sig1=:, the base64 Ed25519 signature, :. |
X-Request-Id | A UUID v4 for this attempt. Not signed. |
| Request | Covered components |
|---|---|
GET status lookup | "@method" "@target-uri" "authorization" |
Every POST, balance included | "@method" "@target-uri" "authorization" "content-type" "content-digest" |
Check in this order, and answer any failure with 401 authentication_failed and WWW-Authenticate: Bearer realm="wallet-api", without saying which check failed:
- The token matches one you issued to us. Refuse a request in which
Authorization,Signature-Input,Signature,Content-TypeorContent-Digestappears twice. Signature-Inputhas exactly the components and parameters above.expiresis aftercreatedand at most 300 seconds later,createdis at most 60 seconds ahead of your clock andexpiresat most 60 seconds behind it.- The key ID is one of ours that you registered.
- The SHA-256 of the raw body equals
Content-Digest. Hash the bytes as received, before parsing. - The Ed25519 signature verifies over the signature base. Build
@target-urifrom your configured public base URL and the path we called, base path included, never fromHostor forwarding headers. - The pair of key ID and nonce is new. Register it atomically, in storage shared by all your instances, and keep it at least until
expiresplus 60 seconds.
Only then parse the JSON and process the command. wallet-request-verifier.mjs implements steps 1–5 for Node.js 22 or later, and our Wallet signing vectors let you test any implementation:
import { headersFromRaw, verifyWalletRequest, walletPublicKey } from './wallet-request-verifier.mjs';
const trust = {
tokens: [process.env.LUCKY_WALLET_TOKEN],
keys: new Map([['OUR_KEY_ID', walletPublicKey('OUR_PUBLIC_KEY')]]),
};
// In your HTTP handler, with the raw body bytes:
const headers = headersFromRaw(req.rawHeaders);
const check = headers && verifyWalletRequest(
{ method: req.method, targetUri: `https://wallet.casino.example.com${req.url}`, headers, body: rawBody },
trust,
);
// nonces: a shared store with an atomic insert in production;
// MemoryNonceRegistry from the same module for development.
if (!check?.ok || !(await nonces.register(check.keyId, check.nonce, check.expires))) {
return unauthorized(); // 401 authentication_failed, WWW-Authenticate: Bearer realm="wallet-api"
}
Your Wallet’s responses aren’t signed in v1; TLS protects them. A retry of the same transaction always arrives with a new nonce and signature, so replay protection never blocks a legitimate retry.
What a WalletTransaction contains
Debits, Credits and Reversals share one set of fields. Together they form the transaction’s identity: a repeat of the same transaction_id always carries exactly the same values.
| Field | Meaning |
|---|---|
transaction_id | Our ID of this WalletTransaction. Unique forever within your integration with us. |
operation | debit, credit or reversal, matching the endpoint. |
brand_id, game_id, game_session_id | The Brand, Game and GameSession the money belongs to. |
player_id | Your External Player ID, exactly as you sent it in player.id. |
round_id | The Round the money belongs to. Use it to group a Round’s Debit and Credit. |
amount | {"currency": "EUR", "minor_units": 100}. Money rules |
reason | gameplay, round_close or compensation. |
round_closed | A Credit with reason: "round_close" must carry true, and a Reversal repeats its Debit’s value; nothing else constrains it. Today we send true only on the zero Credit of a Round without a win, and false on every Debit, Reversal and winning Credit. It doesn’t tell you whether a Round is settled. Details |
occurred_at | When the business event happened, in UTC: 2026-10-20T12:01:00.25Z, with up to six fractional digits and no trailing zeros. It doesn’t change on retries. |
original_transaction_id | Reversals only: the Debit being canceled. |
operator_session_token | Your Operator Session Token. Not part of the identity. Details |
All IDs except player_id are lowercase UUID v4 values. Request bodies have no other fields; your receipts may add fields of your own.
Money
- Amounts are whole numbers of the currency’s minor unit, as defined by ISO 4217: EUR 1.00 is
100. minor_unitsranges from 0 to 9,223,372,036,854,775,807. A Debit or Reversal is at least 1; a Credit can be 0.- Parse amounts without losing precision. Values above 253 are valid, and JavaScript’s
Numberor any floating-point type silently rounds them. Use a 64-bit integer type, or BigInt-aware JSON parsing in JavaScript. - The currency is always the GameSession’s currency. If your Wallet can’t hold it, reject the command with
currency_unsupported.
Deduplication: the core rule
Networks lose answers, so we send the same WalletTransaction again until we get a usable receipt. Your Wallet makes that safe by deduplicating on transaction_id:
| You receive | You answer |
|---|---|
A new transaction_id | Check the command, apply it atomically, store the receipt and return it. |
A known transaction_id with the same identity | The original receipt, unchanged: the same outcome, rejection code and balance_after. No second effect. |
A known transaction_id with a different identity, or on another endpoint | 409 transaction_conflict. The original stays as it is. |
- Look the transaction up before checking the player’s session, limits or funds. A repeat must return its original receipt even after the GameSession ended, the Operator Session Token expired or the Game was disabled.
- Serialize concurrent requests with the same
transaction_id, for example with a unique key and a row lock. Two identical requests at once still move money once. - A rejection is final for its ID. A Debit rejected with
insufficient_fundsstays rejected even after the player deposits; a new stake comes with a new ID. - Never expire or delete deduplication records or
preventedmarkers: not after 24 hours, not at the end of a GameSession, not at all. Credits and Reversals can arrive late, and a purged record would let one apply twice. Changing that would need an agreed protocol change.
Balance
POST/v1/wallet/balance
{
"brand_id": "22222222-2222-4222-8222-222222222222",
"game_session_id": "6d1f2c7a-3b4e-4f5a-9c8d-7e6f5a4b3c2d",
"player_id": "player-7f3a9c",
"currency": "EUR",
"operator_session_token": "YOUR_PLAYER_SESSION_TOKEN"
}
{
"identity": {
"brand_id": "22222222-2222-4222-8222-222222222222",
"game_session_id": "6d1f2c7a-3b4e-4f5a-9c8d-7e6f5a4b3c2d",
"player_id": "player-7f3a9c",
"currency": "EUR"
},
"balance": { "currency": "EUR", "minor_units": 50000 },
"observed_at": "2026-10-20T12:00:40Z"
}
Return the current balance in the requested currency, echoing the four identity fields. The balance is a snapshot that reserves nothing; it moves no money. If the Operator Session Token is invalid, answer with a problem response such as 403 authorization_failed: the game then shows no balance instead of a wrong one.
Debits
POST/v1/wallet/debits
{
"transaction_id": "5f0c2a8e-1d4b-4c3e-9a7f-2b6d8e1c4a90",
"operation": "debit",
"brand_id": "22222222-2222-4222-8222-222222222222",
"game_session_id": "6d1f2c7a-3b4e-4f5a-9c8d-7e6f5a4b3c2d",
"game_id": "44444444-4444-4444-8444-444444444444",
"player_id": "player-7f3a9c",
"round_id": "9a3e5c1b-7d2f-4b8a-8e6c-0f1d3b5a7c9e",
"amount": { "currency": "EUR", "minor_units": 100 },
"reason": "gameplay",
"round_closed": false,
"occurred_at": "2026-10-20T12:01:00.25Z",
"operator_session_token": "YOUR_PLAYER_SESSION_TOKEN"
}
A Debit takes a Round’s stake. When a check on a new Debit fails, reject it with the matching code:
| Check | Rejection code |
|---|---|
| A Reversal for this ID already arrived (see Reversals) | transaction_cancelled |
| The Operator Session Token is valid for this player | session_invalid |
| The player may play now: not blocked, self-excluded or over a limit | gameplay_not_allowed |
| The currency is one your Wallet holds | currency_unsupported |
| The balance covers the amount | insufficient_funds |
Then take the amount and store the receipt in the same database transaction:
{
"identity": {
"transaction_id": "5f0c2a8e-1d4b-4c3e-9a7f-2b6d8e1c4a90",
"operation": "debit",
"brand_id": "22222222-2222-4222-8222-222222222222",
"game_session_id": "6d1f2c7a-3b4e-4f5a-9c8d-7e6f5a4b3c2d",
"game_id": "44444444-4444-4444-8444-444444444444",
"player_id": "player-7f3a9c",
"round_id": "9a3e5c1b-7d2f-4b8a-8e6c-0f1d3b5a7c9e",
"amount": { "currency": "EUR", "minor_units": 100 },
"reason": "gameplay",
"round_closed": false,
"occurred_at": "2026-10-20T12:01:00.25Z"
},
"outcome": "succeeded",
"processed_at": "2026-10-20T12:01:00.31Z",
"balance_after": { "currency": "EUR", "minor_units": 49900 }
}
A rejection is a business answer, so it’s also a 200 receipt:
{
"identity": { "…": "the same identity as above" },
"outcome": "rejected",
"rejection_code": "insufficient_funds",
"processed_at": "2026-10-20T12:01:00.31Z",
"balance_after": { "currency": "EUR", "minor_units": 50 }
}
When a Debit is rejected, the Round doesn’t start and no Credit follows.
Credits
POST/v1/wallet/credits
A Round whose Debit succeeded ends with exactly one Credit, unless it’s canceled. The Credit comes in one of two shapes:
| Round result | amount | reason | round_closed |
|---|---|---|---|
| A win | The gross payout, at least 1 | gameplay | false |
| No win | 0 | round_close | true |
- The amount is the gross payout: everything the player won, not net of the stake. The stake was taken by the Debit. A EUR 1.00 stake that wins EUR 2.50 is a Debit of
100and a Credit of250. - A zero Credit moves no money. Store it and return a receipt like any other command: it tells you the Round is over.
- The contract also allows a positive Credit with
reason: "round_close"andround_closed: true. We don’t send one today; accept it if it arrives. - The contract constrains
round_closedin two ways only: around_closeCredit carriestrue, and a Reversal carries its Debit’s value. Don’t reject other combinations; they’re valid by contract even where we don’t send them today. - Don’t require a matching Debit to accept a Credit; our signature proves it’s ours.
round_closed: falseDespite its name, round_closed doesn’t mean “this Round is settled”. A winning Credit carries false and is still the Round’s last command: a Round has at most one Debit and one Credit, linked by round_id. Close a Round in your books on its Credit, or on the Reversal of its Debit, whatever round_closed says. Waiting for true leaves every winning Round open. Acceptance scenario 1 checks this.
A Credit settles a Round that already happened. Accept it after the GameSession ended, after the Operator Session Token expired or was revoked, and after the player left; operator_session_token may be absent. The only rejection code a Credit can carry is currency_unsupported. A rejected Credit leaves a payout owed to the player, and the Round stays in settlement_incident; contact us when that happens.
Reversals
POST/v1/wallet/reversals
A Reversal cancels a Debit in full, and exists to cancel a Round. No current flow cancels a Round, so you may not see one yet, but your Wallet must support it. A Reversal has its own transaction_id, reason: "compensation" and its own occurred_at. It names the Debit in original_transaction_id, and its player, Brand, Game, GameSession, Round, amount, currency and round_closed equal the Debit’s. Partial Reversals and Reversals of Credits don’t exist.
Serialize Reversals and Debits on the original transaction ID, because a Reversal can arrive before its Debit. The first Reversal for a Debit decides:
| State of the original Debit | Your answer | Money |
|---|---|---|
| Succeeded | succeeded, reversal_effect: "refunded" | Return the Debit’s exact amount, once. |
| Not received yet | succeeded, reversal_effect: "prevented" | Nothing. Store a permanent marker for the original ID. |
| Rejected | succeeded, reversal_effect: "no_effect" | Nothing. |
The Debit arrives after a prevented | Reject the Debit with transaction_cancelled | Nothing. |
| The same Reversal again | The original Reversal receipt | Nothing more. |
| Another Reversal ID for the same Debit | rejected, original_already_reversed, with first_reversal_id | Nothing more. |
| Fields that don’t match the original Debit | 409 transaction_conflict | Nothing; never move money to another player. |
prevented is a promise: once you answer it, the original Debit must never take money later. A Wallet that can’t keep that marker can’t conform to v1. Like Credits, Reversals must be accepted after the GameSession or the Operator Session Token expired.
Transaction status
GET/v1/wallet/transactions/{transaction_id}
When an answer is lost, we ask what happened before we send anything again. Answer with one of three results:
| State in your Wallet | Answer |
|---|---|
| Processed, succeeded or rejected | 200 with {"status": "receipt", "transaction_id": "…", "receipt": {…}}, the original receipt |
| Recorded but still being processed | 200 with {"status": "pending", "transaction_id": "…"} |
| No record | 404 problem with code: "not_found" |
A lookup reads and never creates anything. It needs no Operator Session Token and works after the GameSession ended. not_found describes this moment only: a delayed request can still arrive, and if it does, process it normally.
We count a 404 as “no record” only when it carries a complete problem body with code: "not_found". Any other 404, for example from a proxy, is a failed lookup, and a failed lookup never makes us resend.
Receipts
identityechoes every field of the command exceptoperator_session_token, with exactly the same values. We compare them all; an answer whose identity doesn’t match is unusable.outcomeissucceededorrejected. A rejection carries arejection_code; a succeeded Reversal carries areversal_effect.processed_atis when you processed the command, in the same UTC format asoccurred_at.balance_afteris the balance right after this command, in its currency. It’s optional, but send it: the game shows it to the player after each Round. On a repeat it’s the original value, not today’s balance.- Leave out optional fields you don’t use; never send
null. You may add fields of your own; we ignore them.
| Rejection code | Allowed for | Meaning |
|---|---|---|
insufficient_funds | Debit | The balance doesn’t cover the stake. |
session_invalid | Debit | The Operator Session Token isn’t valid. |
gameplay_not_allowed | Debit | The player may not play now. |
transaction_cancelled | Debit | A Reversal arrived first. |
currency_unsupported | Any | Your Wallet doesn’t hold this currency. |
original_already_reversed | Reversal | Another Reversal already canceled this Debit; send its ID in first_reversal_id. |
HTTP status and what we make of it
A business decision, success or rejection, is always 200 with a receipt. Every other answer is a transport problem in application/problem+json, with type, title, status, detail, code, request_id (equal to your X-Request-Id) and retryable.
| Status | Code | Use it when |
|---|---|---|
| 400 | malformed_request | The request isn’t valid JSON or HTTP. |
| 401 | authentication_failed | Our token or signature didn’t verify. |
| 403 | authorization_failed | We may not perform this request. |
| 404 | not_found | Status lookup only: no record of the transaction. |
| 409 | transaction_conflict | The transaction ID is bound to a different command. |
| 413 | payload_too_large | The body is too large. |
| 415 | unsupported_media_type, unsupported_content_encoding | Wrong media type or encoding. |
| 422 | validation_failed | A field breaks the schema. |
| 429 | rate_limit_exceeded | You’re throttling us. Add Retry-After. |
| 500 | internal_error | Something failed on your side. |
| 503 | service_overloaded, dependency_unavailable | Temporarily unavailable. Retry-After helps us back off. |
| 504 | request_timeout | You ran out of time. |
Only a 200 receipt whose identity matches the command settles a WalletTransaction for us. A timeout, a dropped connection, a malformed body or any problem response leaves its outcome unknown, because your Wallet may have applied the command before the answer was lost. We never read an error as “no money moved”.
How we retry
- A retry repeats the same
transaction_idwith the same body fields. Only the nonce, the signature, the timestamps andX-Request-Idare new. We never create a new transaction ID to work around a failure, and a timeout alone never makes us send a Reversal. - After an unclear answer we usually ask the status endpoint first, then resend only if your Wallet has no record.
- Current defaults, which are configuration and can change: up to 3 attempts within about 15 seconds, then status lookups at randomized, growing intervals from about 5 minutes up to an hour, and at most 10 sends of one transaction. A
Retry-Afterin seconds or as an HTTP date (IMF-fixdate) delays the next attempt; one beyond 24 hours holds the transaction for review on our side. - We stop resending a Debit after its delivery deadline, which is never later than the GameSession’s expiry; status lookups continue. Credits and Reversals have no such deadline.
The failure matrix lists each case, and Rounds and reconciliation shows how this looks in a Round.
Operator Session Token
The Operator Session Token is the value you sent in operator_session_token when you created the GameSession. It stands for the player’s session or Wallet context on your side, and its format and lifetime are yours.
- We send it with every balance request and every Debit. Validate it there.
- Credits and Reversals carry it when we still have it, and may come without it. Never require it there, and never reject them because it expired.
- Repeats and status lookups don’t depend on it: check for an existing transaction first.
- Keep it valid for as long as the player plays. When it expires mid-session, new Debits fail with
session_invalid. A relaunch sends the same token again and doesn’t help: issue a new token and create a new GameSession with a new Idempotency-Key, as Relaunch and re-entry describes. Money of the old GameSession keeps settling under its original transaction IDs.
We store the token encrypted, never show it to the browser, never return it and never log it. It’s not part of the transaction identity, so it can differ between attempts.
Implementation checklist
- All five endpoints exist on a public HTTPS origin, with the response headers above and a
Content-Typewithout parameters. - Requests verify against our token, our key and the time window; nonces are registered once.
- Amounts are parsed and stored as 64-bit integers.
- Deduplication by
transaction_idhappens before any session or balance check, and its records are never deleted. - Credits and Reversals succeed after the GameSession and the Operator Session Token ended.
- Reversals before Debits leave a permanent marker, and the late Debit is rejected with
transaction_cancelled. - Receipts echo the full identity and include
balance_after. - Your Wallet passes the acceptance scenarios.