Skip to main content

Debit — type: "bet"

POST{base}/transaction

The 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​

FieldSentRule
typealwaysbet. The direction is the type's — amount is always positive.
amountalwaysThe stake. Positive.
currencyalwaysISO 4217.
referencealwaysYour idempotency key. Unique per bet, and the same value we send back when settling it.
playerIdservice-key calls onlyA player placing a bet is signed in, so normally absent.
simulationconnection test onlytrue marks a connection test. Ignore it, answer success, move no money.
betalwaysThe 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.

FieldRule
idOur 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.
kindSINGLE, PARLAY or SYSTEM.
statusWhere the ticket stands at this movement. PENDING on a debit; WON, LOST, REFUND or CASHED_OUT later.
stakeStake per combination. Equals totalStake except on a system ticket.
totalStakeWhat the ticket costs in full — on a debit, the same number as amount.
totalOddsCombined decimal odds across the legs.
potentialPayoutWhat the ticket pays if every leg comes in.
payoutWhat it actually paid. null until something settles.
system{ size, combinations } on a SYSTEM ticket, null otherwise.
placedAt, settledAtISO-8601. settledAt is null while the ticket is open.
selections[]Every leg of the ticket, one entry each:
Selection fieldRule
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.
priceDecimal odds snapshot taken at placement.
statusThe 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.

StatusMeansEffect
402Not enough balance.The only refusal the player reads as a real message. The slip stays as it was.
401 403Our credentials are wrong.Alerts us. Configuration, not the bet.
400 422Malformed request.Our bug — tell us.
404Unknown player.Generic failure.
409reference conflicts with a different movement.Generic failure. A repeat of the same movement is 200, not 409.
Other 4xxRefused, definitively.Settles the movement.
5xxYour 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​

  1. Idempotency. The same reference never moves money twice — Duplicate protection below is the part of the contract your side implements.
  2. 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:

  1. Look up reference before 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.
  2. 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.
  3. Seen before, different movement: 409. The same reference naming another amount, type or player is a conflict, never an overwrite.
  4. Deduplicate by reference, never by the signature headers. A repeat is a new HTTP request: it carries a fresh X-Timestamp and X-Nonce and 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:

SendExpect
The same debit twiceOne balance movement, two identical 200 bodies.
The same debit again after restarting your walletStill the stored 200, still one movement.
The same reference with a different amount409, 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 balance
402 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.