A player has one balance per currency, split in two parts: paid, bought with real money, and bonus, granted or earned for free. This page reads a wallet, credits free currency and debits currency; every change is recorded in the ledger. Selling a currency for real money is a checkout, not a grant. The examples on this page continue from the setup.
balances has one line per active currency, zeros included: here gold is there although the player never received any. A currency that is archived disappears from the list.
total is paid + bonus. Only paid comes from real money, which is what a refund takes back.
A balance can be negative after a refund of coins the player had already spent (the default of a game; the game setting « Après un remboursement » in the dashboard can stop balances at zero instead). The amount spent shows as a debt on paid, and the next credits repay it first. A spend never makes a balance negative.
Credits free currency to a player: a quest reward, a daily gift, a compensation. It is for your backend only: the client API cannot credit a player, except through a gift code that you created.
A currency code of the catalog: 2 to 24 characters, a lowercase letter then lowercase letters, digits or _ (gems, gold).
amount
integer
yes
A whole number from 1 to 1,000,000,000,000.
reason
string
no
Free text, at most 500 characters, recorded in the ledger.
metadata
object
no
Free string to string pairs recorded in the ledger: at most 20 entries, keys of 1 to 64 characters (letters, digits, _, ., -), values of at most 500 characters.
An unknown field (paid, bonus…); amount not an integer between 1 and 10¹²; currency malformed; reason too long; metadata with more than 20 entries (METADATA_TOO_LARGE), an invalid key or a value that is not a string; a key that is not 1 to 100 printable ASCII characters
Read details.fieldErrors.
403
PLAYER_BLOCKED
The player is blocked
Nothing can be written for this player until the player is unblocked.
404
NOT_FOUND
The currency is not in the catalog (or is archived), or a GameCoin id does not exist
A grant always credits the bonus part, whatever the currency. paid coins only come from packs bought with real money, and a body field named paid is refused. The one exception is a player in debt (see Get a wallet): the credit repays the debt first, and the entry's paidDelta and bonusDelta show where it went.
Derive the key from the event you reward, such as quest-17-user-42, so that a job that runs twice grants once. The SDKs generate a key for you if you give none, and expose the header as replayed (Replayed in Go and C#) on the result.
reason and metadata are for you: they come back in the ledger. Keep a quest id or a reward name there, never anything personal.
The first write on an unknown ext: player creates it.
Debits a currency from a player: they use coins, you charge for a revive, an entry fee, an unlock. To sell an item for coins, use Buy an item with currency: it debits and delivers in one step.
When the balance is too low, nothing is spent and the answer is 409 INSUFFICIENT_FUNDS, with what was needed and what the player has. Here is how to handle it:
An unknown field; amount not an integer between 1 and 10¹²; currency malformed; reason too long; metadata invalid; a key that is not 1 to 100 printable ASCII characters
Read details.fieldErrors.
403
PLAYER_BLOCKED
The player is blocked
Nothing can be written for this player until the player is unblocked.
404
NOT_FOUND
The currency is not in the catalog, or a GameCoin id does not exist
Replay. The same key with the same request returns the original response again, with the header Idempotent-Replayed: true, and changes nothing.
Bonus coins are spent first, then paid ones, which is why the example above leaves paidDelta at 0. A game can reverse this order in its settings (« Ordre de dépense » in the dashboard). The entry records both deltas.
A spend is all or nothing: it never takes part of the amount and never leaves a negative balance. After a refund left a player in debt, their available amount is 0.
A request that failed with INSUFFICIENT_FUNDS is not stored: once the player has more coins you can retry it with the same key.
A spend on an unknown ext: player creates the player, then fails with INSUFFICIENT_FUNDS.
The browser can spend too, with the player's own token: Spend currency in the client API.