Skip to content

POST messages

Sportsbook sends POST messages to display current information about players, bets, frontend elements, errors, etc.

If you want to handle post messages you can use this code

json
window.addEventListener("message", event => {
        if (typeof event.data === 'string') {
            const messageData = JSON.parse(event.data);
            // do something with messageData
        }
    }, false);

Common messages

The table below describes common messages that sends Sportsbook.

MessageDescription
{
    "type":"route",
"location": string
}
Displays the current route.
{
    "type":"size",
"height": number
}
Displays the height of the iFrame in px.
{
    "type":"user",
"authorized": bool
"cid": string
}
Displays if the user is authorized.
Shows the user’s API key.
{
    "type":"demo",
"status": bool
}
Displays if the demo version is turned on.
{
    "type":"session",
    "status":"ok" // or 'error'
"reason": error.message // in case of 'error'
}
In case of an error on the current session, the message displays the status “error” and the error cause.
{
    "type":"socket",
    "status":"ok" // or 'error'
"reason": error.message // in case of 'error'
}
In case of a socket error, the message displays the status “error” and the error cause.
{
    "type":"click",
    "target":"loginButton"
}
This post message is sent if the SDK initialization specifies this parameter loginUrl: 'sendPostMessage' and when the user click on the "Login" button

Bets messages

The table below describes messages that contain information on placed bets.

MessageDescription
{
    "type":"addBet",
"id": string
}
Displays the id of the added bet.
{
    "type":"clickPlaceBet",
"betType": string
}
Shows if the bet is ordinar or express. The message appears after clicking the bet.
{
    "type":"placeBetFailure",
"status": string, // 'Zero balance' or 'User not logged in'
"statusId": number // 1 or 2
}
The message appears when the user tries to place a bet without logging in or with zero balance.
{
    "type":"placeBet",
"betType": string, // 'ordinar' or 'express'
"bets": array,
"amount": number
}
The message appears when the user places a bet.
The message shows:
if the placed bet is ordinar or express;
an array of prepared bets;
an amount of prepared bets.
{
    "type":"placeBetError",
"betType": string, // 'ordinar' or 'express'
"error": error.message
}
Error message when placing an ordinar or express bet.

Bet Slip messages

The table below describes the POST messages about Bet Slip.

MessageDescription
{
    "type":"theme",
    "subscriber":"betslip",
"data": {
     "value": string
},
}
Shows the name of the current color theme.
{
    "type":"init",
"subscriber":"betslip",
"data": {
     betslipText: "Bet Slip",
     mybetsText: "My bets",
     count: number, // bets length
},
}
The message shows:
name of Bet Slip and My bets buttons (A; B):
![](https://lh4.googleusercontent.com/vFnWRfcArkYYsNuiwPH7FrbJy80mQLl31aoTj9TU5kvdwFx3SD74o7oBHZ-cmMSoNCjXf-ansgooIIE5K0ap6xVQsdrs-GfPeNHYdoUV8_otlX1WZKVZof_j0Ww4IkiA3kVdzEVj)
an amount of bets in Bet Slip.
{
    "type":"count",
    "subscriber":"betslip",
"data": {
     value: number, // bets length
    },
}
Displays a number of bets in Bet Slip.

Mobile messages

The table below describes messages referring to mobile devices.

MessageDescription
{
    "type":"toggle",
    "subscriber":"betslip",
"data": {
     value: bool, // true or false
},
}
The message displays if the Bet Slip panel is visible on mobile devices.
{
    "type":"getInit",
    "subscriber":"main",
}
The message shows that the main iFrame is initiated.
{
    "type":"action",
    "subscriber":"main",
"data": {
     name: string, // 'setModalSearchOpen' / 'setBetSlipOpen' / 'setModalMybetsOpen' / 'setModalSettingsOpen'
     value: bool, // true or false
},
}
The message shows:
if the navigation pop-up window is open or closed;
if the Bet Slip pop-up window is open or closed;
if the My bets pop-up is open or closed;
if the Settings pop-up is open or closed.