Wallet callback reference

The three commands we post to your callback URL, how to verify the signature that comes with them, and what your platform has to answer.

This reference lists only fields verified against a live integration

It is deliberately shorter than the full payload. Where a field is not listed here, take its name from the samples that come with your credentials rather than assuming one — a short accurate reference is worth more than a complete guessed one, and unlike a guessed one it survives contact with your first request.

How the callback works#

We POST JSON to the callback URL you registered for a currency. Your platform answers from its own ledger, and the response body carries the resulting balance. The exchange below is the shape every command shares.

Request

POST /your/callback/url
Content-Type: application/json
X-Signature: 2f5a9c1e0d7b4a3856e9c2f1b8d40a7639ec5182b04d7fa93c6e185207bd4c3a

Response 200

{
  "balance": 1250
}

Note the request line. It targets your URL, not ours — that single detail is the difference between this integration and the REST wallet most teams arrive expecting.

Verifying X-Signature#

Every request carries an X-Signature header holding a hex-encoded HMAC-SHA256. The signed payload is the raw bytes of the request body, exactly as they arrived.

Never sign a re-serialised body

Parsing JSON and serialising it again changes key order, whitespace and number formatting. The digest changes with it and every legitimate request starts failing verification. Capture the raw bytes in your framework before any body parser touches them, verify, and only then parse.

Node.js

const crypto = require('crypto');

// Verify before parsing. rawBody must be the bytes as they arrived —
// a Buffer, not an object that has been through JSON.parse and back.
function verify(rawBody, headerSignature, secret) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(rawBody)
    .digest('hex');

  const a = Buffer.from(expected, 'utf8');
  const b = Buffer.from(headerSignature || '', 'utf8');

  // Constant-time compare: a length check first, because
  // timingSafeEqual throws on mismatched lengths.
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

Compare in constant time. A plain string comparison leaks how much of the digest matched, which is enough to forge one given patience.

getBalance#

Returns the player’s balance. We send it before a round starts, and the answer decides whether the round starts at all.

Response fields

FieldTypeRequiredDescription
balancenumberYesThe player’s balance in the currency the callback URL is registered for.

Response 200

{
  "balance": 1250
}

A failed getBalance must stop the round

Never answer with a cached figure, a default, or a zero standing in for an error. A round that starts against a balance your ledger did not actually confirm settles against it too, and unwinding that afterwards is far more expensive than a game that declines to load.

writeBet#

Applies a round’s financial outcome. The bet and the win arrive together in one call — there is no separate debit command and no separate credit command, so a handler that models them as two operations will be modelling something this API never sends.

Request fields

FieldTypeRequiredDescription
transactionIdstringYesIdentifies the transaction. Repeats are possible and must be handled — see idempotency below.
betnumber or stringYesThe amount staked. May arrive as either type; see parsing notes.
winnumber or stringYesThe amount won on the same round. Zero for a losing round.

Response fields

FieldTypeRequiredDescription
balancenumberYesThe balance after the bet and the win have both been applied.

Request

{
  "transactionId": "5f2a9c31-6d84-4b17-9e30-71c4a8d6f2b0",
  "bet": 100,
  "win": 250
}

Response 200

{
  "balance": 1400
}

Starting from the 1250 above: 1250 minus a bet of 100 plus a win of 250 leaves 1400. Answer with the figure your ledger holds once both have been applied, not the one it held when the request arrived.

rollback#

Undoes a transaction. Sent when a round could not be completed.

Request fields

FieldTypeRequiredDescription
transactionIdstringYesThe transaction to undo. This is the same identifier the original call carried.

Response fields

FieldTypeRequiredDescription
balancenumberYesThe balance after the transaction has been restored.

Request

{
  "transactionId": "5f2a9c31-6d84-4b17-9e30-71c4a8d6f2b0"
}

Response 200

{
  "balance": 1250
}

A rollback for a transaction you never received is a success

Answer 200. It is not an error and it must not be reported as one: the transaction it refers to does not exist on your side, which means the state the rollback is asking for is already the state you are in. Returning an error here strands the round in our system with nothing able to clear it.

Restore once. A second rollback for the same transaction changes nothing further.

Idempotency and duplicates#

Retries happen. Networks time out after your platform has already committed, and the safe response to that is another attempt, so your handler will see the same transactionId more than once.

A duplicate transactionId returns 200 with the current balance and applies nothing

Not a 409, not an error, and above all not a second application of the same bet. Look the transaction up before you write it; if you have it, answer with the balance you already hold.

  • A duplicate writeBet applies nothing and returns the current balance.
  • A rollback restores once, however many times it arrives.
  • In every success response, balance is the balance after the operation — including the case where the operation was a duplicate and therefore did nothing.

Status codes#

CodeMeaning
400Bad request. Insufficient funds is one of the conditions reported this way.
401Unauthorized. The request was not accepted as authentic.
409Conflict.
500Server error.

There is no 402

It is a natural guess for insufficient funds and it is not used here — 400 covers that case. Naming the code that does not exist saves an integrator an afternoon of waiting for one.

Parsing notes#

bet and win arrive as numbers from some studios and as strings from others. Both are valid and both will reach you in production, so parse defensively rather than asserting a type.

Request, same shape, string amounts

{
  "transactionId": "9c0b7e44-2f18-4a5d-8c61-0ba3d97e5412",
  "bet": "50.00",
  "win": "0"
}

Two consequences worth planning for. Convert to your ledger’s own numeric type at the edge of the handler rather than deeper in. And never compare amounts as strings: "50.00" and 50 are the same amount and are not the same string.

Credentials and environments are covered in sandbox access. The reasoning behind the model is in seamless wallet integration.

Last reviewed . Something wrong or missing on this page? Tell us.