Sessions and launch
Real mode creates a game session whose 256-bit launch token is stored only as its SHA-256; demo mode creates no session and accepts no callbacks.
Launch a game
POST /v1/sessions takes a player_id of 1 to 44 characters, a currency, a game_id, a language (ISO 639-1), a country (ISO 3166-1 alpha-2), a device, a return_url and a mode. The return_url must be an https URL: a javascript:, data: or http: URL is refused with MALFORMED_REQUEST and never reaches a provider. Create a session lists every field. The answer is 201 with a game_url to open for the player.
Real mode and demo mode
In real mode the aggregator creates a session for the player and the game, with a random 256-bit launch token that it stores only as its SHA-256. The provider’s callbacks carry that token, and every callback of a live session keeps it alive. A session expires 24 hours after its last callback, or after the shorter idle time set for your client. Only a bet needs a live session; a win or a rollback of an earlier bet is still served after it expires.
In demo mode the aggregator asks the provider for its demo URL and creates no session, so session_id and expires_at are null, and no callback is ever accepted for it. A game without a demo mode is refused with DEMO_NOT_SUPPORTED.
Refused launches
The game must be enabled for your client; an unknown game, a disabled one and another client’s game all answer 404 with NOT_FOUND. A currency that the game, its provider or your client does not offer is refused with CURRENCY_NOT_SUPPORTED (422) before anything is written. When the provider fails to answer, the launch is 502 with INTERNAL_ERROR. A launch is never repeated by the SDK: a second real-mode request creates a second session; a demo launch creates none. The errors page lists the codes.
Sportsbook frames
The BSW sportsbook answers frame, the data its frame boots with, in place of game_url. The ElectroBets sportsbook answers a game_url like a game: open it in an iframe. Every page load is a new launch: a reload asks for a new session instead of reusing the URL. The ElectroBets page posts two postMessage events to your page: iframeHeight, which carries height, the height to give the iframe so that it fits the sportsbook, and onRouteChange, which carries newURL, the sportsbook page the player moved to, which you may keep in your own address bar or history. Check event.origin against the origin of the game_url before you act on an event.
Sportsbook shows how to boot the BSW frame and how sportsbook money reaches your wallet.