API reference: calls you receive
Withdraw
We take the stake of a bet. One attempt only: a withdraw with no clear answer is rolled back, never sent again.
POST {wallet-url}/withdraw
- Called
- for every paid bet (a free bet has no withdraw)
- Timeout
- your debit timeout: 2,000 ms unless agreed otherwise (500–5,000 ms)
- Retries
- never: an unknown outcome is rolled back
- Idempotency key
provider_tx_id
Take amount from the player's balance and answer with the new balance. In Crash each of a player's two bets in a round is a bet of its own, with its own ids, taken during the betting window.
Request#
| Field | Type | Presence | Meaning |
|---|---|---|---|
user_id | string (1–128 chars) | required | Your player reference: the user of the launch. |
currency | string | required | The session currency (the round's currency). |
amount | integer (≥ 1) | required | The stake in units. Move exactly this amount. |
provider | string | required | Our provider key. |
provider_tx_id | string | required | Our transaction id, <roundId>:debit: a string, not a number. Unique for ever and the same on every attempt: deduplicate on it, and on nothing else. |
game | "dice" | "limbo" | "mines" | "plinko" | "crash" | "chicken" | "keno" | "tower" | "hilo" | required | The game identifier. |
action | "bet" | required | Always bet. |
action_id | string | required | The bet's id, <roundId>. |
session_token | string | required | Our token for this game session: 64 lower-case hex characters, made at launch and sent in every later call of the session, also after it ended. It is not a credential. |
platform | "mobile" | "desktop" | required | mobile or desktop, from the browser that opened the launch. |
The ids we send#
| Field | Value | Length |
|---|---|---|
provider_tx_id | <roundId>:debit | 42 characters |
action_id | <roundId> | 36 characters |
Every id is a JSON string, never a number. <roundId> is a UUID written as 36 characters: lower-case hex digits (0–9, a–f) and four hyphens. A suffix is a colon and lower-case letters, so each id always has the length shown. The longest id we send in any call is <roundId>:rollback, 45 characters. Store our ids as strings of at least 45 characters and compare them exactly: a numeric column, or a shorter one, cannot hold them.
Answer#
| Field | Type | Presence | Meaning |
|---|---|---|---|
code | integer | required | The outcome: see the codes. Always answer with HTTP status 200. |
message | string | optional | A short text for people. We do not read it, except on a 412 to withdraw. |
data | object | required with code 200 | The result. Required with code 200 (and, on a money method, with 409). |
data.user_id | string | optional | Must equal ours if present. |
data.operator_tx_id | any JSON | optional | Your transaction id, any JSON value. We keep it for support. |
data.provider | string | optional | Ignored. |
data.provider_tx_id | string | optional | Our provider_tx_id. Must equal ours if present; required on a 409, where it shows that the stored transaction is ours. |
data.old_balance | integer | optional | The balance before the call, in units. Checked to be an integer, not used. |
data.new_balance | integer | required in data | The balance after the call, in units. Shown rounded down. From a 409 it is not used as a figure: it may be older than the balance already shown. |
data.currency | string | optional | Must equal ours if present. |
Examples#
Request
{
"user_id": "u_829301",
"currency": "USD",
"amount": 5320,
"provider": "banzaro",
"provider_tx_id": "0192f3c1-7a5b-7cc3-9d2e-1f2a3b4c5d6e:debit",
"game": "dice",
"action": "bet",
"action_id": "0192f3c1-7a5b-7cc3-9d2e-1f2a3b4c5d6e",
"session_token": "5f2b8c1d9e3a4f60718293a4b5c6d7e8f9012345678901234567890123456789",
"platform": "mobile"
}Accepted
{
"code": 200,
"message": "ok",
"data": {
"user_id": "u_829301",
"operator_tx_id": "559",
"provider": "banzaro",
"provider_tx_id": "0192f3c1-7a5b-7cc3-9d2e-1f2a3b4c5d6e:debit",
"old_balance": 49992,
"new_balance": 44672,
"currency": "USD"
}
}Already processed (409)
{
"code": 409,
"message": "already processed",
"data": {
"user_id": "u_829301",
"operator_tx_id": "559",
"provider": "banzaro",
"provider_tx_id": "0192f3c1-7a5b-7cc3-9d2e-1f2a3b4c5d6e:debit",
"old_balance": 49992,
"new_balance": 44672,
"currency": "USD"
}
}Refused (402)
{
"code": 402,
"message": "insufficient funds"
}Reality check (412)
{
"code": 412,
"message": "You have played for 60 minutes. Take a short break?"
}Codes and what we do#
Only 401, 402, 403 and 412 say "nothing was taken": the bet is voided without a rollback. Every other answer that is not a success ends in a rollback of this withdraw.
| Code | Meaning | What we do |
|---|---|---|
200 | Taken. | The round opens and plays. |
401 | Invalid token. | The bet is voided, no rollback; the session ends. The player sees "Your session has ended. Please reopen the game from the lobby." |
402 | Not enough money. | The bet is voided, no rollback. The player sees "Not enough balance for this bet." |
403 | Expired token. | As 401. |
405 | Internal error, do not retry. | We roll the withdraw back and void the bet. The player sees "The wallet is not responding. Nothing was charged; please try again." |
409 | Already processed. | With our provider_tx_id in data: a success, and the round plays (its stored balance is not shown). Without it: an unknown outcome, so we roll back and raise an alert. |
412 | Reality check. | The bet is voided, no rollback; the session stays open. The game shows the reality-check window with your message. |
413 | Our signature did not verify. | Rollback, as 405, and an alert. |
500 | Any other error (and any code not listed here). | Rollback, as 405. |
When there is no usable answer#
An unknown outcome means the call may or may not have been applied. For withdraw: we roll it back, and void the bet.
| What arrived | Read as |
|---|---|
| No answer within the timeout, a network error, a redirect (never followed) | unknown outcome |
| HTTP status 500 or higher, whatever the body says | unknown outcome |
HTTP status below 500 with a JSON body and an integer code | the code counts, whatever the HTTP status |
A body that is not JSON, has no integer code, or has code 200 without the required data fields of the right type (amounts by the integer rule) | unknown outcome |
Code 200 whose data.provider_tx_id, data.user_id or data.currency differs from ours | unknown outcome |
A money method answered 409 without our provider_tx_id in data | unknown outcome, and an alert on our side |
| A code this method does not list | read as 500 |
What the player sees meanwhile#
While a withdraw has no answer the game shows the bet as pending. Once you have answered 408 twice to the rollback of a withdraw that got no answer, about 33 seconds after the bet, the bet is answered as not placed (error 409 BET_NOT_PLACED) and the player reads: "The bet was not placed. If the stake was taken, it will be returned automatically." That answer stays the same for every retry of the bet. If the bet has no such answer within 60 seconds (your wallet is still down, say), the game tells the player the bet is still being processed. A rolled-back bet may end void only after our re-checks, up to about 5 minutes 30 seconds after it was placed (see the late withdraw), and later while your wallet does not answer the rollback. A void bet is never listed in the player's history, which lists settled rounds only; the balance is whole, or whole again once a re-check returns the stake.