Debit — type: "bet"
POST{base}/transactionThe stake leaving the balance. We call it the moment a bet is accepted and do not record the ticket until you answer.
All four types (bet, win, rollback, prize) reach the same {base}/transaction address; type tells
them apart.
Request
| Field | Sent | Rule |
|---|---|---|
type | always | bet. The direction is the type's — amount is always positive. |
amount | always | The stake. Positive. |
currency | always | ISO 4217. |
reference | always | Your idempotency key. Unique per bet, and the same value we send back when settling it. |
playerId | service-key calls only | A player placing a bet is signed in, so normally absent. |
simulation | connection test only | true marks a connection test. Ignore it, answer success, move no money. |
bet | always | The whole ticket behind the movement — legs, markets, prices, totals. See below. |
The ticket — bet
Every movement carries the full ticket it moves money for. Every field is
always present: what does not apply yet is spelled null, never a missing
key.
| Field | Rule |
|---|---|
id | Our ticket id — quote it when you raise a movement with us. null on a debit and on the refund of a failed one: the ticket is recorded only after you answer, so at that moment reference is the only key. Set on every later movement. |
kind | SINGLE, PARLAY or SYSTEM. |
status | Where the ticket stands at this movement. PENDING on a debit; WON, LOST, REFUND or CASHED_OUT later. |
stake | Stake per combination. Equals totalStake except on a system ticket. |
totalStake | What the ticket costs in full — on a debit, the same number as amount. |
totalOdds | Combined decimal odds across the legs. |
potentialPayout | What the ticket pays if every leg comes in. |
payout | What it actually paid. null until something settles. |
system | { size, combinations } on a SYSTEM ticket, null otherwise. |
placedAt, settledAt | ISO-8601. settledAt is null while the ticket is open. |
selections[] | Every leg of the ticket, one entry each: |
| Selection field | Rule |
|---|---|
fixture | { id, name, startDate } — the event the leg is on. startDate is ISO-8601 or null. |
sport, league, market | { id, name } pairs down the catalog, ids in the provider's naming. |
selection | { id, name, line } — the outcome the player picked. line is the number the market priced it on ("7.5", "-1.5" on totals and handicaps) and null on the markets that price none: for those markets name is only the direction ("Under"), so the two together are the whole selection. |
price | Decimal odds snapshot taken at placement. |
status | The leg's own settlement status: PENDING, WON, LOST, REFUND, HALF_WON, HALF_LOST. |
Refusing
The status is the answer. A 200 means the money moved — nothing in the body
overrides it.
| Status | Means | Effect |
|---|---|---|
402 | Not enough balance. | The only refusal the player reads as a real message. The slip stays as it was. |
401 403 | Our credentials are wrong. | Alerts us. Configuration, not the bet. |
400 422 | Malformed request. | Our bug — tell us. |
404 | Unknown player. | Generic failure. |
409 | reference conflicts with a different movement. | Generic failure. A repeat of the same movement is 200, not 409. |
Other 4xx | Refused, definitively. | Settles the movement. |
5xx | Your wallet is down. | Transient — we retry. |
A body such as { "error": "INSUFFICIENT_FUNDS" } alongside the status reaches our
logs. Diagnostics, not contract.
4xx settles, 5xx retries. Answering 500 for a poor player makes us retry against
a wall; answering 402 for a database outage settles a bet that should have been
retried.
Rules
- Idempotency. The same
referencenever moves money twice — Duplicate protection below is the part of the contract your side implements. - One call per bet. Five singles in the slip are five sequential requests, each seeing the balance the previous one left. Never a batch, never an array.
A stake we took and could not turn into a ticket is refunded immediately, same
reference as parentReference — see Rollback.
Duplicate protection
The same bet will reach you more than once. A dropped connection, a
redeploy or the player pressing again all end in a repeat, and we re-send an
unconfirmed bet ourselves — seconds later, automatically, and again whenever
the player retries. A repeat is normal traffic, not an attack, and reference
is what makes it safe. Implement exactly this:
- Look up
referencebefore touching the balance. First time seen: move the money, and store the reference and the answer you are about to send in the same database transaction as the movement. A crash between the movement and the record is how one bet becomes two debits. - Seen before, same movement: answer the stored result. Same
200, same body, no new movement — however much later the repeat arrives. The balance in that body is the one the original movement left, not a fresh read. - Seen before, different movement:
409. The samereferencenaming anotheramount,typeor player is a conflict, never an overwrite. - Deduplicate by
reference, never by the signature headers. A repeat is a new HTTP request: it carries a freshX-TimestampandX-Nonceand they must verify as usual (signature). The nonce guards the transport; the reference guards the money.
Before going live, run these three against your implementation:
| Send | Expect |
|---|---|
| The same debit twice | One balance movement, two identical 200 bodies. |
| The same debit again after restarting your wallet | Still the stored 200, still one movement. |
The same reference with a different amount | 409, no movement. |
POST {base}/transaction
Authorization: Bearer <the player's own token>
Content-Type: application/json
{
"type": "bet",
"amount": 10.00,
"currency": "USD",
"reference": "bet_9f2c1e4a",
"bet": {
"id": null,
"kind": "SINGLE",
"status": "PENDING",
"stake": 10.00,
"totalStake": 10.00,
"totalOdds": 2.10,
"potentialPayout": 21.00,
"payout": null,
"system": null,
"placedAt": "2026-08-16T15:04:05.000Z",
"settledAt": null,
"selections": [
{
"fixture": {
"id": "11223344",
"name": "Real Madrid vs Barcelona",
"startDate": "2026-08-20T19:00:00.000Z"
},
"sport": { "id": "6046", "name": "Football" },
"league": { "id": "38", "name": "LaLiga" },
"market": { "id": "1", "name": "1X2" },
"selection": { "id": "271", "name": "Real Madrid", "line": null },
"price": 2.10,
"status": "PENDING"
}
]
}
}
curl -s -X POST "https://casino.example.com/api/sportsbook/transaction" \
-H "Authorization: Bearer <the player's session token>" \
-H "Content-Type: application/json" \
-d '{
"type": "bet",
"amount": 10.00,
"currency": "USD",
"reference": "bet_9f2c1e4a",
"bet": {
"id": null,
"kind": "SINGLE",
"status": "PENDING",
"stake": 10.00,
"totalStake": 10.00,
"totalOdds": 2.10,
"potentialPayout": 21.00,
"payout": null,
"system": null,
"placedAt": "2026-08-16T15:04:05.000Z",
"settledAt": null,
"selections": [
{
"fixture": {
"id": "11223344",
"name": "Real Madrid vs Barcelona",
"startDate": "2026-08-20T19:00:00.000Z"
},
"sport": { "id": "6046", "name": "Football" },
"league": { "id": "38", "name": "LaLiga" },
"market": { "id": "1", "name": "1X2" },
"selection": { "id": "271", "name": "Real Madrid", "line": null },
"price": 2.10,
"status": "PENDING"
}
]
}
}'
200The money moved{ "ok": true, "balance": 90.50, "currency": "USD", "externalTxId": "TX-55192" }
externalTxId is optional (transactionId accepted as an alias).
402Not enough balance402 Payment Required
200The SAME reference again — the stored answer, no new movement{ "ok": true, "balance": 90.50, "currency": "USD", "externalTxId": "TX-55192" }
Byte-for-byte the first answer: the balance the original movement left, the original transaction id. See Duplicate protection.
Next: Credit — paying the bet out.