Rollback

Live
POST{base}/api/rollback

Sent when the provider needs to change the result of a round that already ended. Debit back what you credited: amount for a round you settled, bet_amount for one you refunded. Then put the round back into a running state.

Process the whole txns[] batch in one DB transaction (atomic) — if any txn fails, roll back the batch and reply an error with balance_before == balance_after

If the same txn_id arrives again, do not apply it a second time; reply the current balance with code 0, or reply 20002. The only exception is a transaction that follows a /rollback of that round: it carries a corrected result and must be applied (see "re-settle after rollback" on the Contract page).

A 0 amount is real — a feature spin, a bought feature, a tip, or a stake the provider could not supply. Do not reject it: process it as a zero-value transaction and reply code 0 without moving the balance.

BY_TRANSACTION acts on this txn_id only. BY_ROUND acts on every bet in the same round_id at once, and amount is the round's combined total.

Always reply HTTP 200 even for business errors

After a rollback the round may be settled or cancelled again under the same txn_id. Deduping on txn_id alone drops the corrected transaction. Count the rollbacks you have received per txn_id (BY_TRANSACTION) or per round_id (BY_ROUND) and make that count part of your idempotency key — the same round can be rolled back more than once (see "re-settle after rollback" on the Contract page).

Headers

FieldTypeRequiredDescription
X-Api-KeystringYesThe API key best-system issued to you (verify it matches)
X-SignaturestringYeshex(HMAC-SHA256(secret, raw body)) — verify against the raw bytes, never re-serialize. Mismatch → code 30002

Request bodyapplication/json

FieldTypeRequiredDescription
request_idstringYesId of this request
player_usernamestringYesThe player's username on your system
currencystringYesThe player's currency code in ISO 4217, e.g. THB
product_codestring—Game-provider code (e.g. PGSOFT)
timestampnumberYesSend time in unix milliseconds
txnsobject[]YesRollbacks — debit back what you credited: use `amount` (a prior settle's payout) or `bet_amount` (a prior refund's stake), depending on the bet's prior state on your side
└ txn_idstringYesTransaction ID. Used as the idempotency key (see the notes)
└ round_idstringYesRound ID
└ amountnumberYesAmount for this transaction, never negative and may be 0 (see the notes). Direction comes from the endpoint or the direction field
└ game_codestring—Game code
└ is_featureboolean—Whether this is a free or feature spin. Absent means false
└ statusstring—Vendor bet status. Always ROLLBACKOPEN | WAITING | SETTLED | REFUND | REJECT | ROLLBACK | VOID | TIPS
└ play_infostring—The player's position or choice, e.g. player/banker, or the game name. `UNKNOWN` means the provider could not identify it — display only
└ transaction_typestring—Either BY_TRANSACTION or BY_ROUND (see the notes)BY_TRANSACTION | BY_ROUND
└ bet_amountnumber—The stake — debit this back when the bet's prior state was a **refund** (you had credited the stake back) · if the prior state was a settle, debit `amount` (the payout) instead · may be 0 when the prior state was a settle
└ payout_amountnumber—The round's previously paid payout. Same value as amount (informational — the value to apply is amount)
└ ref_txn_idstringYestxn_id of the original settle/refund being withdrawn (the txn that credited the wallet) — not found → reply 20001
Request example
{
  "request_id": "8d7c6b5a-4e3f-4210-9f8e-7d6c5b4a3f2e",
  "player_username": "foobar",
  "currency": "THB",
  "product_code": "PGSOFT",
  "timestamp": 1783236604000,
  "txns": [
    {
      "txn_id": "T-008",
      "round_id": "R-1",
      "amount": 500,
      "game_code": "10300",
      "is_feature": false,
      "ref_txn_id": "T-002"
    }
  ]
}

Expected Response

Fields in data

FieldTypeRequiredDescription
codenumberYes0 = success · see the Seamless codes page
request_idstringYesEchoed from the request
usernamestringYesEcho of player_username (defensive)
currencystringYesEchoed from the request
balance_beforenumberYesBalance before processing the whole txns[] batch
balance_afternumberYesBalance after processing the whole batch
timestampnumberYesWhen you processed it (unix ms)
Response example
{
  "code": 0,
  "request_id": "8d7c6b5a-4e3f-4210-9f8e-7d6c5b4a3f2e",
  "username": "foobar",
  "currency": "THB",
  "balance_before": 1300,
  "balance_after": 800,
  "timestamp": 1783236604102
}

Possible error codes

codeNameHTTPMessage
10001SEAMLESS_USER_NOT_FOUND200Player not found on the agent system
10002SEAMLESS_INSUFFICIENT_BALANCE200Insufficient balance for the debitThe player may have already spent the payout, leaving insufficient balance to debit back
20001SEAMLESS_TXN_NOT_FOUND200Referenced transaction (ref_txn_id) not found
20002SEAMLESS_DUPLICATE_TXN200Duplicate transaction (txn_id already processed)
30002SEAMLESS_INVALID_SIGNATURE401Invalid X-Signature
40003SEAMLESS_FORBIDDEN200Forbidden (api-key/IP)
50001SEAMLESS_INTERNAL_ERROR200Internal error on the agent system