> 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/cancel.md).

# Cancel

This request is triggered when a player's bet action fails to complete successfully—due to reasons such as network issues, timeouts, or system errors. In such cases, the request serves to refund the full bet amount back to the player's balance to ensure fairness and maintain account accuracy.

{% 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: "cancel",
   transactionId: "215202",
   playerId: "1101",
   roundId: "65215842315484512",
   providerId: 2,
   providerName: "EGT Digital",
   gameCode: "FSHBLSlot",
   gameName: "40 Burning Hot Bell Link",
   currency: "EUR",
   amount: 10,
   timestamp: 1586335186372
}
</code></pre></td></tr><tr><td>Response Body</td><td><pre class="language-json"><code class="lang-json">{
   balance: 1591.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>referenceId</strong></td><td>string</td><td>Y</td><td>The transaction id of the bet transaction which should be canceled.</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>Refund amount.</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\_TRANSACTION\_DOES\_NOT\_EXIST | The referenced transaction is not initiated in operator's system. |
| ERR\_TRANSACTION\_ROLLED\_BACK     | The referenced transaction is already reversed.                   |
| 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.&#x20;

{% hint style="info" %}
A response must be provided within 4 seconds. If the callback request times out or returns a specific error, our API will automatically retry the request up to 2 more times.
{% endhint %}

## Example

### Request

```json
{
   command: "cancel",
   transactionId: "SP215202",
   referenceId: "SP215201"
   playerId: "1101",
   roundId: "65215842315484512",
   providerId: 2,
   providerName: "EGT Digital",
   gameCode: "FSHBLSlot",
   gameName: "40 Burning Hot Bell Link",
   currency: "EUR",
   amount: 10,
   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_TRANSFER_DOES_NOT_EXIST",
    "balance": 19839890
}
```
