Seamless Wallet Endpoints: getbalance & balance_adj
Essential credentials required to integrate: API Encryption Key, Operator ID
For the Seamless Wallet functionality to work, the RGS-CWS will need to send HTTP POST requests to two URLs provided by your team:
getbalance: to retrieve player wallet balance.balance_adj: to update player wallet (bet, win, cancelbet, cancelwin).
Callback URLs in the trial environment
In the trial environment, the RGS calls only the getbalance and balance_adj URLs you registered in the API access request. Callback URLs sent in a request are not used there. To change the registered URLs, contact us. Callback URLs per request are a feature of the final installation on your own server.
These endpoints must follow our security and response guidelines. Be sure to read Security โ Trusting Our Data for hash validation setup and other guidelines.
IMPORTANT: Our games will send data to your endpoints, only when the game is opened in โreal modeโ. โfun modeโ will not send any data to your endpoints.
NOTE: It is also important for your code to respond in a short amount of time and avoid timing out. We consider a timed out transaction to be a transaction with a response time >=5 seconds. After this time, the transaction is retried once, right away. If no success, it will be put in a queue and it will be cancelled (cancel request being sent once every 5 minutes - this interval increases and becomes less frequent)
๐ณ getbalance Endpoint
Used by RGS-CWS to request the current balance of a player from your platform.
RGS-CWS will send a JSON string in a POST request. You must decode and parse it. The structure is as follows:
๐ Sample JSON Request from RGS-CWS to your server - getbalance:
POST /getbalance.php
{
"command":"getbalance",
"userid":"224",
"login":"u241_8841",
"timestamp":"2026-07-02 14:10:00",
"currency":"USD",
"internal_session_id":"abc123",
"uniqid":"a1b2c3d4e5f6",
"type":"getbalance",
"custom_data":"",
"hashed_result":"05ea6df60e2ba0a14facb2128e083f4cf288493b7cbc5f614b8348aae638172d"
}With the key your-secret-key, the hashed_result of this sample request is the value shown: use it to test your own signature code before the first real request.
๐ฅ Input Parameters (coming from RGS-CWS) - getbalance:
Parameter | Always Present | Description | DataType |
| โ | Must be | string |
| โ | Unique RGS-CWS user ID. You can ignore | string |
| โ | Username from your system, that you originally passed when registering the user or generating the game play token โ but it will be prefixed. You must replace โu241_โ with โโ(nothing) , assuming 241 is your operator id. Player username (may include currency suffix in format: username_CURRENCY, e.g., "john_USD". Remove the suffix to get the original username) | string |
| โ | The date and time when the request was generated, in GMT ( | string |
| โ | Currency code (e.g. | string |
| โ | PHP Session ID | string |
| โ | Unique ID of current Request | string |
| โ | This has always the value โgetbalanceโ for this endpoint | string |
| โ | This represents the value of the custom_data string that you initialized when you generated the game token. If you did not set any value, it will be empty. | string |
| โ | HMAC-SHA256 signature ; key=your This is obtained by hashing these variables, in this exact order:
Sample hashing code: | string |
IMPORTANT: The
loginwill always contain a prefix.
For production the prefix is โu241_โ, where 241 is your operator id. This is different for every operator.
For staging the prefix is โstg_u241_โ, where 241 is your operator id. This is different for every operator.
You must trim this prefix.
IMPORTANT: Theloginparameter may also contain a currency suffix in the following format:username_CURRENCY
Examples:
-john_USD(user "john" playing with USD)
-player123_EUR(user "player123" playing with EUR)
-testuser_BTC(user "testuser" playing with BTC)Please remove the currency suffix from the end of the login string. You can find a code snippet below on how to do it properly.
Warning: When writing your code, make sure you do the trimming only at the end to avoid scenarios where the currency code appears in the username itself. For example, if the currency isCOINSand the username isjoe_coinstar, you should NOT accidentally remove_coinsfrom the middle of the username.
$operatorid = 241;
//REMOVE THE PREFIX (only at the start): stg_u241_ in the trial / staging environment, u241_ in production
foreach (array('stg_u'.$operatorid.'_', 'u'.$operatorid.'_') as $prefix) {
if (strpos($login, $prefix) === 0) {
$login = substr($login, strlen($prefix));
break;
}
}
//REMOVE CURRENCY SUFFIX (only at the end)
$suffix = '_'.strtoupper($currency);
if (substr($login, -strlen($suffix)) === $suffix) {
$login = substr($login, 0, -strlen($suffix));
}
๐ค Output Response Format (Expected from your server) - getbalance:
{
"status": "1",
"balance": "2221212.44"
}
A balance reply is accepted when status is "1" and balance is a number of 0 or more. With any other reply (another status, no valid JSON, no reply in time, or a wrong reply signature) the balance is not read and the player cannot play; a balance request is not sent again. For a getbalance read only the JSON body is read: the HTTP status code of your reply does not change the result. (A balance_adj refusal is different: see the win_rejected article โ a status -1 sent inside an HTTP 5xx error is treated as not delivered.)
A login your platform does not know must be refused with {"status":"-1","errormsg":"Invalid user"}, on getbalance and on balance_adj. Never create a new wallet for it.
Reply signature (hash)
Every reply you send to a getbalance or balance_adj request must carry a hash field. The check is enabled by default for every operator account, in the trial environment too. A reply with a missing or wrong hash is treated as no reply: a win is held and sent again with the same uniqid until a correctly signed reply arrives, a bet is not taken, and a balance is not read.
How to build it:
Build the string
status|balance|uniqid:statusโ the status value you return, as the exact string you send (for example1).balanceโ the balance you return, as the exact string you send (for example1250.50). When the reply has nobalancefield, use thecreditfield's string instead.uniqidโ theuniqidvalue from our request, unchanged.
Sign it with HMAC-SHA256 using the same secret key you use to verify our requests.
Send the result as a lowercase hexadecimal string in the
hashfield.
Send status and balance as JSON strings, so the bytes you sign are the bytes we read.
Example (key your-secret-key):
reply : {"status":"1","balance":"1250.50","hash":"6bcbaa67aef69e9cb5d9d477222b3f4ecd7322f252bf1eda4007e19315c6bfa8"}
string to sign : 1|1250.50|a1b2c3d4e5f6
hash : HMAC-SHA256("your-secret-key", "1|1250.50|a1b2c3d4e5f6") as hex
= 6bcbaa67aef69e9cb5d9d477222b3f4ecd7322f252bf1eda4007e19315c6bfa8Send the hash field on every reply from your first integration test. The automated test tool checks it (test 15). Ask us only if you need the check switched off during a migration.
๐ธ balance_adj Endpoint
Used by RGS-CWS to notify your system about real-time wallet changes like bets, wins, cancels.
RGS-CWS will send a JSON string in a POST request. You must decode and parse it. The structure is as follows:
๐ Sample JSON Request from RGS-CWS to your server - balance_adj
POST /balance_adj.php
{
"command": "balance_adj",
"amount": "-25.0000",//4 decimals precision, sent as string, not float
"userid": "1441",
"login": "u241_166273",
"type": "bet",
"timestamp": "2025-07-02 14:00:00",
"gpid": "100",
"uniqid": "1ee2a1a9c481f330cdb5f701d9c78bef",
"gameid": "6857",
"internal_session_id": "abc123",
"gpid_status": "nt",
"currency": "USD",
"custom_data": "",
"subtype": "gamble",
"is_jackpot_win": "1",
"hashed_result": "..."
}
๐ฅ Input Parameters (coming from RGS-CWS) - balance_adj:
Parameter | Always present | Description | Data Type |
| โ | Must be | string |
| โ | Amount to adjust. Negative = bet, Positive = win. 4 decimal max | string |
| โ | RGS-CWS internal user ID | string |
| โ | Username from your system, that you originally passed when registering the user or generating the game play token โ but it will be prefixed. You must replace โu241_โ with โโ(nothing) , assuming 241 is your operator id. Player username (may include currency suffix in format: username_CURRENCY, e.g., "john_USD". Remove the suffix to get the original username) | string |
| โ | One of: | string |
| โ | The date and time when the request was generated, in GMT ( | string |
| โ | Game play ID (can be repeated across related transactions like freespins) | string |
| โ | Game round status: | string |
| โ | Game ID, e.g. | string |
| โ | Session identifier from RGS-CWS system. It has no specific purpose. | string |
| โ | Unique transaction ID. Use this to ensure idempotency | string |
| โ | Currency code (e.g. | string |
| โ | The value of the | string |
| โ | Optional. E.g. | string |
| โ | If present and set to | string |
| โ | HMAC-SHA256 signature ; key=your This is obtained by hashing these variables, in this exact order:
Sample PHP hashing code: | string |
๐ค Output Response Format (Expected from your server) - balance_adj:
Your endpoints must return a valid JSON response with the following fields:
Parameter | Required | Description | Type |
| โ |
| string |
| โ | New user balance (as a string with decimals). If no update was made, please return the current balance value. | string |
| โ | Recommended. The transaction ID from your system (a number or alphanumeric). We store it with the transaction. | string |
| โ | Message shown to the player if status is | string |
๐ด Important: Returning
"status": "-1" or "status": "0"means the transaction is permanently rejected and will not be retried.
โ Example for success
{
"status": "1",
"balance": "22221212.44",
"txid": "TX3890021"
}
โ Example for failure
{
"status": "-1",
"balance": "22221212.44",
"errormsg": "Insufficient Balance"
} Reply signature (hash)
Every reply you send to a getbalance or balance_adj request must carry a hash field. The check is enabled by default for every operator account, in the trial environment too. A reply with a missing or wrong hash is treated as no reply: a win is held and sent again with the same uniqid until a correctly signed reply arrives, a bet is not taken, and a balance is not read.
How to build it:
Build the string
status|balance|uniqid:statusโ the status value you return, as the exact string you send (for example1).balanceโ the balance you return, as the exact string you send (for example1250.50). When the reply has nobalancefield, use thecreditfield's string instead.uniqidโ theuniqidvalue from our request, unchanged.
Sign it with HMAC-SHA256 using the same secret key you use to verify our requests.
Send the result as a lowercase hexadecimal string in the
hashfield.
Send status and balance as JSON strings, so the bytes you sign are the bytes we read.
Example (key your-secret-key):
reply : {"status":"1","balance":"1250.50","hash":"6bcbaa67aef69e9cb5d9d477222b3f4ecd7322f252bf1eda4007e19315c6bfa8"}
string to sign : 1|1250.50|a1b2c3d4e5f6
hash : HMAC-SHA256("your-secret-key", "1|1250.50|a1b2c3d4e5f6") as hex
= 6bcbaa67aef69e9cb5d9d477222b3f4ecd7322f252bf1eda4007e19315c6bfa8Send the hash field on every reply from your first integration test. The automated test tool checks it (test 15). Ask us only if you need the check switched off during a migration.
โ Best Practices
Remove prefixes and suffixes from the username
Always validate the hashed_result signature
Always verify if the user has sufficient funds in his wallet before applying balance adjustments. EG: if (amount<0 && wallet_balance+amount>=0) only then process it and make sure to update your local balance right away. If you use SQL, you can do conditional query and see number of affected rows after your query, to determine if the balance was updated or not
UPDATE users SET balance=balance+amount WHERE user=โmyusernameโ AND balance>=amount.Now count the number of affected rows (must be 1).Log all transactions, even failed ones, for auditability.
Optimize your setup by NOT updating the balance when the amount is 0$, but store the transactions for idempotency and gameplay progress tracking
Always validate that incoming transactions are not duplicated using the
uniqidfield. If you processed a transaction in the past, do not process it again.Use a timestamp window (e.g. 15 minutes) to reject expired requests.
When receiving a
cancelbetorcancelwin, search and reverse the matching original transaction or rely on the amount value that we send to apply to the player balance.
EG: a bet request like this{"type":"bet","amount":"-25","uniqid":"891h591gajsoeg"}will have an equivalent cancelbet such as this{"type":"cancelbet","amount":"25","uniqid":"cancel_891h591gajsoeg"}Always send amounts as numeric strings with 2 to 4 decimal places (e.g.,
"25.00","0.1234").Do not reject duplicate transactions silently โ always reply with
status: 1if already handled.
๐ Verifying Signature
If hashed_result is included, verify it using your API secret key. Read more here.
//Sample code to validate the hashed string in the balance_adj endpoint
//Sample code to validate the hashed string in the balance_adj endpoint
$calculated_hash = hash_hmac('sha256', json_encode(array(
$data['command'],
$data['timestamp'],
$data['login'],
$data['internal_session_id'],
$data['uniqid'],
$data['type'],
$data['userid'],
$data['custom_data'],
$data['amount'], //in getbalance this is not sent so please adjust accordingly
$data['gameid'], //in getbalance this is not sent so please adjust accordingly
$data['gpid'], //in getbalance this is not sent so please adjust accordingly
$data['currency'],
), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), $api_encryption_key);
$sent_hash = $data['hashed_result'] ?? '';
if (!hash_equals($calculated_hash, $sent_hash)) { // โ Changed from $hashed_result to $sent_hash
// Invalid signature - reject the request
http_response_code(403);
echo json_encode(['status' => '-1', 'balance' => '0.00', 'errormsg' => 'Invalid signature']);
exit;
}
// Valid - continue processingReject request if computed hash does not match
hashed_resultThis improves trust between RGS-CWS and your system
๐ซ Insufficient Funds
On bet requests, check player's wallet before processing.
If balance is not enough:
Return
status: "-1"Include a proper
errormsgso the game client can display it
{ "status": "-1", "balance": "4.00", "errormsg": "Insufficient balance" }Important: Log rejected transactions for idempotency check
๐ Idempotency
Each transaction comes with a unique
uniqid.You must check if the
uniqidwas already processed by your system (store each uniqid in a database table and perform search queries to see if you already have it processed):If yes, respond with
status: "1"and the last known balance.If no, process the transaction normally and store the
uniqid. Respond adequately (status:"1")
Required to avoid double processing of bets or wins in case of retries.
// Response that your server should return on Duplicate transaction ID
{ "status": "1", "balance": "123.45" }โ๏ธ Cancel Transactions
RGS-CWS may send cancelbet or cancelwin operations if a transaction expires or is rolled back. You can read more about this in the โHandling Timeoutsโ documentation section.
This feature is available only on-demand.
Field | Value | Notes |
|
| Indicates the reversal of a previous bet or win |
|
| Strip |
Best practice: treat
cancel_123456abcdefas a rollback for the transaction withuniqid = 123456abcdef
๐ Retry Policy
Player experience: A win that cannot be confirmed in real time does not block the player โ the game session continues and the win is delivered later by the retry process. A bet requires a confirmed debit from your endpoints: an unconfirmed bet ends the round (reversed via cancelbet if needed).
If your system does not respond within 5 seconds or returns a malformed response:
The same win request will be retried: after 5 minutes, then after 10, 30, 60, 120 and 300 minutes, and every 600 minutes from then on
Bet requests will be cancelled and passed as
type=cancelbetRetries will continue until a valid JSON response with
status: "1"is received
Common reasons for retry: Timeout, No response, Missing/invalid status field in JSON
Common reasons for retry:
Timeout
No response
Missing/invalid
statusfield in JSON
You must ensure that duplicate handling logic is applied via
uniqidThe interval between retries grows with each attempt: 5 minutes for the first, then 10, 30, 60, 120 and 300 minutes, and 600 minutes from then on. The retries do not stop until your endpoint gives a definitive answer.
๐ ๏ธ You can optionally set up a cronjob on your server to execute every 5 minutes and to fetch and process missed wins or bets by polling endpoints described in E27/E28 of the original documentation. You can read more about this in the Handling Timeouts documentation section.