Skip to content

POST /rollback

Beexar → Operator

Beexar sends this request to reverse previously processed transactions (bets or wins). The operator must undo the financial effect of each original transaction.


POST {rollback_url}

HeaderValue
Content-Typeapplication/json
X-REQUEST-SIGNHMAC-SHA256 signature of request body
FieldTypeRequiredDescription
account_idstringYesPlayer account identifier
currencystringYesCurrency code — standard ("USD", "EUR") or custom ("CUSTOM_GOLD")
game_idstringYesGame identifier (slug)
round_id_providerstringYesGame round identifier (Beexar’s round_id)
finishedbooleanYesWhether the game round is finished after this rollback
transactionsarrayYesList of rollback transactions (min 1)
session_idstringNoSession identifier (UUID)

Each item in the transactions array:

FieldTypeRequiredDescription
id_providerstringYesUnique rollback transaction identifier (generated by Beexar)
typestringYesAlways "rollback"
original_id_providerstringYesid_provider of the original transaction to reverse
{
"account_id": "player_123",
"currency": "USD",
"game_id": "slots",
"round_id_provider": "550e8400-e29b-41d4-a716-446655440000",
"finished": true,
"transactions": [
{
"id_provider": "tx_rb_001",
"type": "rollback",
"original_id_provider": "tx_bet_001"
}
],
"session_id": "7b115688-3849-490a-95bd-7c281d81c64c"
}

FieldTypeRequiredDescription
balancestringYesPlayer balance after rollback
round_idstringYesRound identifier on operator side
transactionsarrayYesResults for each rollback transaction

Each transaction result:

FieldTypeRequiredDescription
id_providerstringYesRollback transaction identifier from request (echo back)
idstringYesTransaction identifier assigned by operator (may be empty if original was not found)
{
"balance": "500.00",
"round_id": "697962ac-fd0d-4dc2-b52c-e850e40825dc",
"transactions": [
{ "id_provider": "tx_rb_001", "id": "op_tx_201" }
]
}
HTTP StatusTwirp Codeapi_codeDescription
400invalid_argument403Invalid or missing signature
500internal500Internal server error

Terminal window
curl -X POST https://casino.example.com/wallet/rollback \
-H "Content-Type: application/json" \
-H "X-REQUEST-SIGN: abc123def456..." \
-d '{
"account_id": "player_123",
"currency": "USD",
"game_id": "slots",
"round_id_provider": "550e8400-e29b-41d4-a716-446655440000",
"finished": true,
"transactions": [
{
"id_provider": "tx_rb_001",
"type": "rollback",
"original_id_provider": "tx_bet_001"
}
]
}'

These rules are critical for correct rollback implementation:

  1. If the original transaction exists — reverse it and return the updated balance

    • Rollback of a bet → credit the bet amount back to the player
    • Rollback of a win → debit the win amount from the player
  2. If the original transaction does NOT exist — create a tombstone and return a valid response (NOT an error)

    • The tombstone prevents the original transaction from being processed if it arrives later
    • This handles the case where rollback arrives before the original transaction due to network timing
  3. Tombstone prevents late processing — if a BetWin arrives and a tombstone exists for that id_provider, the transaction must be rejected (api_code 155)

  4. Process rollback even if player has insufficient funds — if rolling back a win would make the balance negative, still process it

  5. Duplicate rollback — if the same id_provider is received again, return the original response, do NOT reverse the transaction again

  6. Idempotency applies to id_provider (the rollback’s own ID), not original_id_provider


TriggerDescription
Game errorAn error occurred in the game engine after the bet was confirmed but before the result was determined
Bonus/Free-Spins timeoutIn multi-step games (slots), if the player does not complete a bonus or free-spins session within the timeout period
Crash game win failureIf the win wallet call fails during cashout, the win is rolled back asynchronously
Stale betsIf a bet is stuck in a transitional state for too long, the system rolls it back automatically

sequenceDiagram
    participant Beexar
    participant Wallet as Operator Wallet

    Note over Beexar,Wallet: Scenario 1: Normal rollback
    Beexar->>Wallet: POST /betwin (bet tx_bet_1)
    Wallet-->>Beexar: 200 OK
    Beexar->>Wallet: POST /rollback (original: tx_bet_1)
    Wallet->>Wallet: Reverse bet, credit player
    Wallet-->>Beexar: 200 { balance }

    Note over Beexar,Wallet: Scenario 2: Tombstone (rollback before bet)
    Beexar->>Wallet: POST /rollback (original: tx_bet_2)
    Wallet->>Wallet: tx_bet_2 not found, create tombstone
    Wallet-->>Beexar: 200 { balance }
    Note right of Wallet: Later, if tx_bet_2 arrives...
    Beexar->>Wallet: POST /betwin (bet tx_bet_2)
    Wallet->>Wallet: Tombstone exists, reject
    Wallet-->>Beexar: 400 { api_code: "155" }