> ## Documentation Index
> Fetch the complete documentation index at: https://docs.igamingace.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel

The `cancel` callback is sent when a player's bet fails to complete — due to network issues, timeouts, or system errors. Your server must refund the full bet amount back to the player's balance to ensure account accuracy. This operation is idempotent — if your wallet receives more than one request with the same `transactionId`, you must register the refund only once.

***No need to add "Cancel" at the end of your callback URL; you can get the request body "command" to identify which callback is coming.***

* **URL:** Your configured Callback URL(ex: [***https://mycallback.com/cb***](https://mycallback.com/cb))
* **Method:** POST
* **Headers:** `X-Request-Signature`, `Content-Type`, `Accept`

## Request parameters

<ParamField body="command" type="string" required>
  Always `"cancel"` for this callback type.
</ParamField>

<ParamField body="transactionId" type="long" required>
  Unique reference of this cancel transaction created in our system. Use this to enforce idempotency.
</ParamField>

<ParamField body="playerId" type="string" required>
  Unique identifier of the player from your system.
</ParamField>

<ParamField body="roundId" type="long" required>
  Unique reference of the game round.
</ParamField>

<ParamField body="providerId" type="number" required>
  Unique identifier of the game provider in our system.
</ParamField>

<ParamField body="gameCode" type="number" required>
  Unique game id of the game in our system.
</ParamField>

<ParamField body="timestamp" type="number" required>
  Unix timestamp of the request.
</ParamField>

## Response fields

Your server must respond with HTTP 200 and a JSON body containing the following fields:

<ResponseField name="balance" type="number" required>
  The player's updated balance after the refund is applied.
</ResponseField>

<ResponseField name="statusCode" type="string" required>
  Result of the operation. Must be `"OK"` on success. See the status codes table below for all possible values.
</ResponseField>

## Status codes

| Status code                      | Description                                                  |
| :------------------------------- | :----------------------------------------------------------- |
| `OK`                             | Request successful                                           |
| `ERR_NOT_AUTHENTICATED`          | The player is not authenticated                              |
| `ERR_TRANSACTION_DOES_NOT_EXIST` | The referenced bet transaction does not exist in your system |
| `ERR_TRANSACTION_ROLLED_BACK`    | The referenced transaction has already been reversed         |
| `ERR_INTEGRITY_CHECK_FAILED`     | Message integrity check failed                               |
| `ERR_UNKNOWN`                    | Internal server error                                        |

<Warning>
  Your response must be returned within **4 seconds**. If the request times out or returns an error, we will automatically retry the request up to **2 more times**.
</Warning>

<Tip>
  Use `referenceId` to locate the original bet in your database. If the bet was never recorded (e.g., your system never received it), you can safely return `OK` with the player's current balance — there is nothing to refund.
</Tip>

## Examples

<CodeGroup>
  ```json Request theme={null}
  {
    "command": "cancel",
    "transactionId": "SP215202",
    "referenceId": "SP215201",
    "playerId": "1101",
    "roundId": "65215842315484512",
    "providerId": 1,
    "gameCode": 655,
    "timestamp": 1586335186372
  }
  ```

  ```json Success response theme={null}
  {
    "balance": 19839891,
    "statusCode": "OK"
  }
  ```

  ```json Error response theme={null}
  {
    "statusCode": "ERR_TRANSACTION_DOES_NOT_EXIST",
    "balance": 19839890
  }
  ```
</CodeGroup>
