API Document

Agent API

An agent, in SEAMLESS or TRANSFER mode, calls best-superapi to open games for its members, to read the catalog and to read its members' bets. An agent in TRANSFER mode also moves money into and out of its members and reads their balances. This page is the contract of those calls, version 1. Every field and every example is also in the OpenAPI file under paths; the examples named below live there.

In SEAMLESS mode none of these calls moves money: money moves only through the callbacks we send to your wallet. In TRANSFER mode we hold your members' balances, and transfer/deposit and transfer/withdraw move money into and out of them (transfers).

The endpoints

Each endpoint is a POST with a JSON body, at the path below. Send {} when there is nothing to send, never an empty body: the signature covers the body, so every request has one. An endpoint of the other wallet mode is answered with 1032.

Path What it does Wallet mode A suspended agent
/api/v1/launch Opens a game for a member and returns its URL Both Refused (1033)
/api/v1/providers Lists the providers, with available for your agent Both Allowed
/api/v1/games Lists the games, page by page Both Allowed
/api/v1/bet-records Lists your members' bets, page by page, with totals per currency Both Allowed
/api/v1/result Returns the result page of a bet Both Allowed
/api/v1/seamless/result The same as /api/v1/result, kept for version 1 (result) SEAMLESS Allowed
/api/v1/credit Returns your agent's credit available now, per currency Both Allowed
/api/v1/members/suspend Suspends one of your customers, in every currency Both Allowed
/api/v1/members/resume Lifts a suspension your agent set Both Allowed
/api/v1/transfer/deposit Moves money into a member TRANSFER Refused (1033), but a resend of a done ref_id answers
/api/v1/transfer/withdraw Moves money out of a member TRANSFER Refused (1033), but a resend of a done ref_id answers
/api/v1/transfer/balance Returns a member's balance in a currency TRANSFER Allowed
/api/v1/transfer/transactions Finds one transfer by ref_id, or lists your transfers page by page TRANSFER Allowed

What each endpoint takes and returns, field by field, is in the OpenAPI file.

Headers and signature

Header Value
Content-Type application/json (when a request is refused)
X-Api-Key The API key of your API credential
X-Timestamp Unix time in seconds when you signed the request
X-Signature Lowercase hex of HMAC-SHA256, keyed with the secret of your API credential, over {X-Timestamp}.{raw body}
Accept-Language Optional. th for message in Thai; English otherwise (the response). It is the only way to choose the language.

To sign a request:

  1. Serialize the body once, and send exactly those bytes.
  2. Compute HMAC-SHA256 of the X-Timestamp value, a dot (.), then the body, with your secret as the key, and send its lowercase hex as X-Signature.
  3. Sign every attempt with the current time. We refuse an X-Timestamp more than 300 seconds away from our clock in either direction, so keep your clock in sync (NTP).

This is the same signature as on the callbacks we send you (headers and signature), with your key and secret on both sides. There is no nonce: within those 300 seconds a request can be sent again, and that is safe: a launch sent again returns a new URL, and a transfer sent again with its ref_id moves nothing.

We do not read X-Contract-Version on your requests: the version is in the path.

An API key can carry an allowlist of the IP addresses that may use it. In production every key must have one; in the sandbox it is optional.

When a request is refused

401 means we cannot tell who sent the request; 403 means we know who sent it and refuse it. The one exception is 1002, the only 403 given before we know who you are. We check in this order and answer the first check that fails:

Check HTTP Code
1. X-Api-Key, X-Timestamp and X-Signature are all present 401 1001
2. We can read the body: send it as application/json 403 1002
3. The API key is known 401 1001
4. The caller's IP is on the key's allowlist 403 1031
5. The signature matches 401 1030
6. X-Timestamp is within 300 seconds of our clock 401 1025
7. The endpoint is for your agent's wallet mode 403 1032
8. The agent is not suspended, on launch 403 1033
9. In production, the key has an IP allowlist 403 1026

On transfer/deposit and transfer/withdraw a suspended agent passes these checks, so that a resend of a done ref_id can answer its first result; a new transfer is then refused with 1033.

Someone without your secret can learn only that a key exists and whether their IP is on its allowlist. Everything after the signature (the clock, the agent's mode and suspension, the production rule) is told only to a request signed with your secret. A refused request does nothing.

The request

Every field of the body is listed in the OpenAPI file. A field the endpoint does not know, a missing required field and a value of the wrong shape are all answered 400 with code 4001, and message names the field.

The response

Every response has the same envelope, and its HTTP status is the real one: 200 on success, and the status of the code on a refusal.

Field Meaning
success true with code 0, false otherwise
code An integer from the table of codes. Decide on it.
message For people only. English by default, Thai with Accept-Language: th. The words may change: never decide on them.
data The result, null on a refusal
request_uuid Our id of the request. Quote it to support.

New fields may be added in version 1: ignore any field you do not know.

Codes

Apart from 0 these codes have four digits, unlike the five-digit codes of callback replies. Each code always comes with the same HTTP status. Decide on code; for a code you do not know, fall back on the class of its HTTP status: a 5xx can pass later, a 4xx needs a change first. The words "offered to you" and "available through us" are defined under catalog.

Code HTTP Meaning Endpoints
0 200 Success All
1001 401 A header is missing, or the API key is unknown All
1002 403 The body could not be checked (send it as application/json) All
1008 403 The member is suspended launch, transfer/deposit
1024 400 The member's username would be too long. A valid request never gets it: an external_player_id over 24 characters is answered 4001. launch, transfer/deposit
1025 401 X-Timestamp is more than 300 seconds away from our clock All
1026 403 In production, the key has no IP allowlist All
1030 401 The signature does not match All
1031 403 The caller's IP is not on the key's allowlist All
1032 403 The endpoint is not for your agent's wallet mode All
1033 403 The agent is suspended launch, transfer/deposit, transfer/withdraw
1034 403 The member's suspension was set by best-superapi, or is a ban, so your agent cannot lift it members/resume
3001 404 The game is unknown, removed or switched off, or you switched it off launch
3002 503 The provider is not available through us, is not offered to you or you switched it off, or the provider refused to open the game launch
3015 422 The provider has no result page for this bet result
3016 404 No bet of yours has this bet_id result
3120 403 The provider is not open for agents through us right now launch
3121 503 The game has no connection through us right now launch
3122 503 The provider has no connection through us right now launch
3123 403 The currency is not enabled on your account; on transfer/withdraw, no currency has this code launch, transfer/deposit, transfer/withdraw
3124 422 The provider or the game does not take this currency launch
3127 503 The game is inside a maintenance window launch
3128 503 The provider is inside a maintenance window launch
3130 409 This ref_id was already used for a transfer of another member, currency, amount or direction transfer/deposit, transfer/withdraw
3131 422 The member's balance in this currency is less than amount transfer/withdraw
3132 409 The member owes money in this currency, so nothing can be withdrawn transfer/withdraw
3133 404 You never made a transfer with this ref_id transfer/transactions
3134 404 You never sent this external_player_id transfer/balance, transfer/withdraw, members/suspend, members/resume
4001 400 A field is missing, unknown or of the wrong shape All
4004 404 No endpoint has this path and method All
4005 422 The range starts more than 90 days ago bet-records, transfer/transactions
9001 500 Something failed on our side All
9002 503 The provider is not reachable through us right now launch, result

Retries and timeouts

Any request can be sent again: only transfer/deposit and transfer/withdraw move money, and a transfer sent again with the same ref_id moves nothing. Sign each attempt with the current time, and leave a growing pause between attempts. Whether sending it again can help depends on the code, as below; for a code not listed here, use the fallback under codes.

  • Send the same request again later after a network error or a timeout, and on 9001 and 9002.
  • On 3127 and 3128, send it again after maintenance_until in the catalog.
  • On 3120, 3121 and 3122 the provider or the game is not available through us: tell support. The request can pass later once our team fixes the setup, so send it again later, never in a tight loop.
  • On 3002, read available of the provider: when it is true, the provider refused this game and a later launch can pass; when it is false, sending again never helps.
  • On 1001, 1030, 1031 and 1026, fix your key, secret, IP or allowlist first. On 1025, set your clock right.
  • On 1002, send the body as application/json.
  • On 1008, launch or deposit again once the member is active again. On 1032, call the endpoint of your agent's wallet mode; your mode itself is set on our side, so ask support if it is wrong. On 1033, your agent's suspension is set on our side: ask support. On 1034, the member's suspension is ours, so ask support, or it is a ban your agent set, which you lift in your backoffice. 1024 is never given to a valid request: ask support.
  • On 3130, the ref_id already names another transfer: look up what you sent with it (transfer/transactions) before you send anything else, and never reuse a ref_id for a new transfer.
  • On 3133 for a transfer that timed out, send that transfer again with the same ref_id, never with a new one: a transfer still in flight when you asked can land after the 3133, and the same ref_id moves money once.
  • On 3131, read the balance with transfer/balance and withdraw at most that. On 3132, the member owes money: a deposit pays the debt first, and a withdraw can pass once the balance is no longer negative.
  • Change the request before sending it again on 3001, 3123, 3124, 3015, 3016, 3134 and 4xxx.

There is no rate limit.

Callbacks work the other way round. Every result of a game goes from the provider to us, to your wallet, and back. We send each callback to your wallet once and never apply a result for you: when a callback fails, we tell the provider, and the provider sends it again. Answer within 3 seconds (time to answer), and apply a resend only once (resends).

How you name a member

  • external_player_id is your id of your customer, the person who plays: lower-case letters and digits, at most 24. You send it to launch and transfer/deposit with a currency. We keep one member per external_player_id and currency: the first launch or deposit of an id in a currency creates the member of that currency. Every callback and every bet record carries both, and your wallet finds the balance by the two together.
  • player_username is our username of the member, made of a prefix of ours and your id. The member of a second currency, and of each one after it, has the lower-case currency code after your id (and a number when that name is taken). It is the name our backoffice shows and support uses. Never find a member by it. This is the one definition; callbacks and bet records point here.

Currencies

  • A currency is an ISO 4217 code in three capital letters (^[A-Z]{3}$), such as THB, JPY or KWD. It is called currency everywhere: in launch, in callbacks, in bet records, and in each provider's supported_currencies.
  • A member has one currency, for good. One external_player_id can play in several currencies: a launch or a deposit in another currency creates the member of that currency, with its own balance. When an external_player_id is suspended, by us or by you (suspending a member), every currency of it is suspended (1008).
  • A launch is refused with 3123 when the currency is not enabled on your account, and with 3124 when the provider or the game does not take it. supported_currencies of a provider lists what it takes.
  • Amounts are JSON numbers in the major unit of the currency, with at most as many decimals as the currency has (THB 2, JPY 0, KWD 3). An amount we send is rounded to those decimals, and a half rounds away from zero, the same way in callbacks and in bet records: 0.005 THB is 0.01, and a winlose of -0.005 THB is -0.01.
  • Amounts in different currencies are never added together: totals come per currency.

Time

  • Every time in a response is RFC 3339 in UTC with milliseconds, ending in Z, such as 2026-01-01T00:00:00.000Z.
  • A time in a request (from and to of bet-records and transfer/transactions) is RFC 3339 with any offset: 2026-01-01T00:00:00Z and 2026-01-01T07:00:00+07:00 are the same instant. Choose the offset of the day you want.
  • Unix time is used only in X-Timestamp (seconds) and in the timestamp of a callback (milliseconds).

Launch

launch takes the member (external_player_id), the game (game_id, the id from games), device_type, lang, return_url, player_ip and currency, and returns launch_url (example launch). Send the member to that URL.

  • player_ip is the IP address of the member's device, never your server's. Some providers need it to open a game, so it is required on every launch.
  • A launch fails when the game cannot be opened for this member now: the codes for launch say why, and retries say what to do.
  • In TRANSFER mode we hold the member's balance: a member launched for the first time in a currency starts at 0 in that currency.
  • A suspended agent cannot launch (1033), and neither can a suspended member (1008). The results of bets already open still come to your wallet as callbacks.

Transfers

In TRANSFER mode we hold the balance of each member, one per currency. transfer/deposit moves money into a member, transfer/withdraw moves it out, transfer/balance reads the balance (examples deposit, withdraw and balance, and success of each response), and transfer/transactions finds the transfers you made. The rules for ref_id and amount are the same in both directions.

  • ref_id is your id of the transfer: 1 to 64 characters (Unicode code points), any text but control characters (U+0000 to U+001F and U+007F) and unpaired surrogates, unique among all your transfers. After a timeout or a network error, send the same request again with the same ref_id: it returns the first result, with the same txn_id, and moves nothing, even if the member or your agent was suspended or the currency was no longer enabled on your account in between. One ref_id names one transfer in either direction: the same ref_id with another member, currency, amount or direction (a ref_id a deposit used, sent to transfer/withdraw, or the other way round) is refused with 3130 and moves nothing. With the same member, currency and direction, an amount that is no amount of the currency is refused with 4001, never matched to the first one.
  • amount is at least one smallest unit of the currency, has at most as many decimals as the currency, and is at most 999999999999999 in its smallest unit (15 digits: 9999999999999.99 THB), the most a JSON number carries exactly; anything else is refused with 4001. A number of up to 15 significant digits is taken as you wrote it, so 1.234 THB is refused. A longer number is float noise of your arithmetic, such as 0.30000000000000004: it is rounded to the currency's decimals (0.3) when it is at most a hundredth of the smallest unit away, and refused with 4001 otherwise. amount in the reply is what we took. Past 15 significant digits a number can reach us as the same JSON number as a shorter one, so round before sending when you can.
  • A deposit to an external_player_id in a currency it has not used creates the member of that currency, with a balance of 0, and then adds the amount.
  • A balance can be negative: the member owes money, for example when a provider takes back a win the member already spent. A deposit pays the debt first. debt_cleared is the part of amount that went to the debt, and balance_after is always balance_before plus amount.
  • A debt in one currency never touches the member of another currency, and never stops play in it.
  • No member of a suspended external_player_id takes a deposit, in any currency (1008). A suspended agent cannot make a new deposit (1033) but can still resend a done ref_id and read balances.
  • A withdraw takes only what the member holds: an amount over the balance is refused with 3131, and while the member owes money (a negative balance) every withdraw is refused with 3132. The whole balance can go, leaving 0. balance_after is always balance_before minus amount.
  • A withdraw in a currency the id has not used is refused with 3131 (its balance is 0) and creates no member. A withdraw of an external_player_id you never sent is refused with 3134. A currency no longer enabled on your account still pays out what its member holds; only a code that is no currency is refused with 3123. A new withdraw is checked in this order: 1033, 3134, 3123, 4001, 3132, 3131.
  • A suspended member can still withdraw, so money never stays where it cannot be played. A suspended agent cannot make a new withdraw (1033) but can resend a done ref_id.
  • transfer/balance of a currency the id has not used is 0. An external_player_id you never sent is refused with 3134.
  • transfer/transactions finds the transfers of your agent in both directions (examples byRefId, oneDay and success). With ref_id it answers that one transfer on page 1 (total 1), or 3133 when you never made a transfer with it; a request that was refused made no transfer. Send ref_id alone: with from, to, external_player_id or currency it is refused with 4001. Without ref_id it lists the transfers made in [from, to), optionally of one external_player_id or one currency, with the range and page rules of bet-records. An external_player_id you never sent lists nothing.
  • Each record holds the figures the deposit or withdraw answered, with its type (DEPOSIT or WITHDRAW), its external_player_id and created_at, the time we made it. amount is never negative, and debt_cleared is 0 on a withdraw. The order is created_at, newest first, then txn_id; keep to fixed while you page through a range.

Catalog

providers lists every provider of the catalog, and games lists their games page by page (examples success of each). Both show state as fields and never filter by it: a provider or game that is switched off is listed with is_active: false.

Two phrases are used with one meaning each:

  • Offered to you is set on your account by whoever opened it (our team or your reseller): the providers on your account, with your share of each, and the currencies of your account.
  • Available through us is set on our side by our team, the same for every agent: the provider is switched on, open for agents, connected and reachable through us.

On the lists:

  • available on a provider is for your agent. It is true only when the provider is available through us, it is offered to you and you have not switched it off, and at least one currency of your account is one the provider takes through us. False means launch refuses the provider whatever the game. There is no available on a game.
  • True means the provider can be launched, but one launch can still be refused for the game: a game switched off on its own (3001), a currency that game does not take (3124), a game with no connection through us right now (3121), a maintenance window of the provider or the game (3128, 3127), or the provider refusing to open the game (3002).
  • Who sets what available depends on: you switch providers (and single games) off and on in your backoffice; what is offered to you is set by whoever opened your account; what is available through us is set by our team.
  • A provider we cannot reach is listed with available: false; it never makes the list fail.
  • A maintenance window is kept apart from available: maintenance_from and maintenance_until give the planned window [from, until), on a provider and on a game. maintenance_from null with a maintenance_until means the window has started; maintenance_until null or in the past means no maintenance. Inside the window launch answers 3128 for the provider and 3127 for the game.
  • A game's code is our code of the game, the game_code of callbacks and bet records. A provider's code is the provider_code of callbacks and bet records.
  • Games of a removed provider are not listed.

Bet records

bet-records lists the bets of your members, page by page (examples oneDay and oneMember, and success of the response).

  • The range is half-open, [from, to), on bet_at. Without from and to it is the last 30 days; with from only it ends now; with to only it is the 30 days before to.
  • A range can reach back 90 days at most. One that starts earlier is answered 422 with code 4005, never cut short.
  • Records can be a few seconds behind: a bet can appear a few seconds after its callback.
  • The order is bet_at, newest first, then id, so pages never repeat or skip a record. Keep to fixed while you page through a range: a bet placed after to then cannot move the pages.
  • Each record carries external_player_id, provider_code, game_code and provider_game_code, with the same meaning as in callbacks. Every key is present. provider_code always has a value; external_player_id, game_code (null when the game is not in our catalog) and provider_game_code are null when unknown.
  • A record's game_code names the game the bet was recorded under, while a callback's game_code is looked up from the provider's code in that callback. The two can differ: when a provider uses one code for more than one game, when the game was added to our catalog or renamed after the bet, or when the callback's lookup did not finish in time (the callback then carries null). Treat game_code as a description of the game, never as a key: money rules use txn_id, amount and direction.
  • On a record of a game played without bets (an adjust without bet_amount), provider_game_code may come from our catalog's record of the provider's code for the game, so it can differ from the one the callback carried.
  • Amounts are rounded to the decimals of the record's currency, a half away from zero (currencies).
  • status is the bet record's own value set (PENDING, SETTLED, VOIDED, CANCELLED), not the status of a callback txn (callbacks).
  • winlose is seen from the member: what the bet paid minus the stake, positive when the member won. payout_status follows the rounded winlose of a SETTLED bet (WIN, LOSE or DRAW) and is UNKNOWN on any other status.
  • summary gives one entry per currency over every bet the filter matches, not only the page. Its totals are rounded once from the exact totals, and the records add up to them, because every stored amount already has the currency's decimals.
  • Bets placed by the connection test in your backoffice are never listed and never counted in summary. The connection test page shows each run step by step, with the requests we sent.

Result

result (/api/v1/result, in either wallet mode) takes bet_id, the id of a bet record, and returns result_url, the result page of the bet, which shows how the round played out (example result). 3015 means the provider has no result page for that bet, and 9002 that the provider could not be reached right now, so send it again later. A bet that is not yours is answered as unknown (3016).

/api/v1/seamless/result takes the same request and gives the same answers, for an agent in SEAMLESS mode only (1032 otherwise). It stays open for all of version 1 so that an agent already calling it keeps working; use /api/v1/result in new code.

Credit

Your agent plays on credit, per currency: the most your members may lose together in that currency. credit returns, for each currency enabled on your account, available: the credit you were given, plus what your members won, minus what they lost, minus the stakes of their bets still open (example credit). It is the figure we check each new bet against, at the moment you call.

  • When a provider sends new stake that is more than available in its currency, we refuse it to the provider: the member sees the bet fail in the game, and in SEAMLESS mode it never reaches your wallet. New stake is a bet, or anything else that puts stake into play, such as raising the stake of an open bet; bets the provider sends together are checked as one total. Results of bets already open always go through.
  • A currency enabled on your account with no credit yet answers 0, and no bet in it passes.
  • available can dip below 0 for a short while when results of open bets arrive together. A new stake passes again once available is at least that stake.
  • Credits of different currencies are never added together.
  • Bets placed by the connection test in your backoffice are not checked against credit and do not change available, so the test runs even when your credit is used up.

Suspending a member

members/suspend suspends one of your customers, external_player_id, in every currency, and members/resume lifts it. Both answer suspended, whether the customer is suspended after the call (examples suspendMember and resumeMember).

  • A suspended customer cannot launch or take a deposit (1008), in any currency. Bets already open still settle and their callbacks still come, and a member in TRANSFER mode can still withdraw. A member in a game when you suspend it is not sent out of the game.
  • Calling members/suspend again suspends only the currencies still active, and members/resume for a customer that is not suspended changes nothing. Both answer the same each time.
  • A customer can be suspended by your agent, through this API or your backoffice, or by best-superapi. members/resume lifts only a suspension your agent set, in every currency of the customer. When best-superapi suspended any currency of it, the suspension is ours and is refused with 1034, here and in your backoffice. A ban is lifted only in the backoffice, so members/resume answers it with 1034 too. When best-superapi suspends a customer you already suspended, the suspension becomes ours.
  • An external_player_id you never sent is refused with 3134.

Versions

The version is in the path: /api/v1/. Version 1 only grows by additions, such as new endpoints, new fields in responses or new values of a list. Ignore any field you do not know. A change that would break an agent built on version 1 comes as a new version, announced ahead, and version 1 stays open beside it for at least 90 days.