> For the complete documentation index, see [llms.txt](https://scorpioplay.gitbook.io/scorpio-play-casino-api-doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://scorpioplay.gitbook.io/scorpio-play-casino-api-doc/api-reference/images-and-media/bet.md).

# Bet

When a player places a bet, our API will issue a callback request to deduct the bet amount from the player's balance and retrieve the updated balance.

{% hint style="warning" %}
This is an idempotent operation. If the wallet receives more than one request with the same `transactionId` the transaction must be registered only once in the wallet.
{% endhint %}

<table data-header-hidden><thead><tr><th></th><th></th></tr></thead><tbody><tr><td>URL</td><td>{operatorCallbackURL}</td></tr><tr><td>Method</td><td>POST</td></tr><tr><td>Headers</td><td>X-Request-Signature<br>Content-Type<br>Accept</td></tr><tr><td>Request Body</td><td><pre class="language-json"><code class="lang-json">{
   command: "bet",
   transactionId: "SP215202",
   playerId: "1101",
   roundId: "65215842315484512",
   providerId: 2,
   providerName: "EGT Digital",
   gameCode: "FSHBLSlot",
   gameName: "40 Burning Hot Bell Link",
   currency: "EUR",
   amount: 10,
   isRoundFinished: true,
   isCall: false,
   timestamp: 1586335186372
}
</code></pre></td></tr><tr><td>Response Body</td><td><pre class="language-json"><code class="lang-json">{
   balance: 1501.52,
   statusCode: "OK"
}
</code></pre></td></tr></tbody></table>

## Request

<table><thead><tr><th width="146">Parameter</th><th width="107">Values</th><th width="104">Mandatory</th><th>Description</th></tr></thead><tbody><tr><td><strong>command</strong></td><td>string</td><td>Y</td><td>Indicates the request type.</td></tr><tr><td><strong>transactionId</strong></td><td>string</td><td>Y</td><td>Unique reference of the transaction created in our API.</td></tr><tr><td><strong>playerId</strong></td><td>string</td><td>Y</td><td>Unique identifier of the player from the operator's<br>system.</td></tr><tr><td><strong>roundId</strong></td><td>string</td><td>Y</td><td>Unique reference of the game round.</td></tr><tr><td><strong>providerId</strong></td><td>number</td><td>Y</td><td>Unique identifier of the provider in our API.</td></tr><tr><td><strong>providerName</strong></td><td>string</td><td>Y</td><td>The name of the provider.</td></tr><tr><td><strong>gameCode</strong></td><td>string</td><td>Y</td><td>Unique identifier of the game in our API</td></tr><tr><td><strong>gameName</strong></td><td>string</td><td>Y</td><td>The name of the game.</td></tr><tr><td><strong>currency</strong></td><td>string</td><td>Y</td><td>Player currency, according to ISO-4217 (EUR, USD ...)</td></tr><tr><td><strong>amount</strong></td><td>number</td><td>Y</td><td>Transfer amount.</td></tr><tr><td><strong>isRoundFinished</strong></td><td>boolean</td><td>Y</td><td>Indicates whether the round is finished or not.<br>If true, no "win" callback will be sent after this callback, but if false, other corresponding callbacks will be sent.<br>For example, if the player wins, "win" callback request should be sent after this callback, so this value would be false. But if the player loses, no more callback needs to be sent, so this value will be true.</td></tr><tr><td><strong>isCall</strong></td><td>boolean</td><td>Y</td><td>If true, Player is in undergoing bonus call event.</td></tr><tr><td><strong>timestamp</strong></td><td>number</td><td>Y</td><td>Timestamp of the request.</td></tr></tbody></table>

## Response

<table><thead><tr><th width="146">Parameter</th><th width="107">Values</th><th width="104">Mandatory</th><th>Description</th></tr></thead><tbody><tr><td><strong>balance</strong></td><td>number</td><td>Y</td><td>Player balance.</td></tr><tr><td><strong>statusCode</strong></td><td>string</td><td>Y</td><td>Status code of the execution.</td></tr></tbody></table>

## Possible Status Codes

| Status codes                  | Reason                                                                   |
| ----------------------------- | ------------------------------------------------------------------------ |
| OK                            | Request successful                                                       |
| ERR\_NOT\_AUTHENTICATED       | Player is not authenticated                                              |
| ERR\_NOT\_ENOUGH\_MONEY       | Player account does not have sufficient funds to complete the operation. |
| ERR\_INTEGRITY\_CHECK\_FAILED | Message integrity check failed.                                          |
| ERR\_UNKNOWN                  | Internal server error                                                    |

In case `statusCode` is different than "OK", the request will be treated as unsuccessful. An unsuccessful bet request will cancel the current game round, meaning the player will not be able to proceed further.\
Depending on the response error type a reversal request may be initiated, to make sure there are no\
remaining open rounds for the particular player at the operator system.

{% hint style="info" %}
A response must be returned within 3 seconds. If the callback request times out or returns a specific error, our API will not retry. If it fails, a 'cancel' request will be sent to revert the current game round.
{% endhint %}

## Example

### Request

```json
{
   command: "bet",
   transactionId: "SP215202",
   playerId: "1101",
   roundId: "65215842315484512",
   providerId: 2,
   providerName: "EGT Digital",
   gameCode: "FSHBLSlot",
   gameName: "40 Burning Hot Bell Link",
   currency: "EUR",
   amount: 10,
   isRoundFinished: true,
   isCall: false,
   timestamp: 1586335186372
}
```

### OK Response

<pre class="language-json"><code class="lang-json">{
<strong>    "balance": 19839891,
</strong>    "statusCode": "OK"
}
</code></pre>

### Error Response

```json
{
    "statusCode": "ERR_NOT_ENOUGH_MONEY",
    "balance": 19839895
}
```
