> For the complete documentation index, see [llms.txt](https://docs.cmswager.com/cmswager-integration-document/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cmswager.com/cmswager-integration-document/client-api-reference/api-reference/cancelling-bets.md).

# Cancelling bets

<mark style="color:green;">`POST`</mark> `{clientApi}/ticket/cancel`

When a ticket is canceled on the Cmswager side, either by the player himself or the manager, a \`ticket/cancel\` request will be sent to the client system.

After canceling the ticket the deposit amount should be added to the user balance. The ticket then should be updated to the status indicated in the request. And if the cancellation is successful, the deposit amount should be refunded to the user.

{% hint style="info" %}
If this request encounters a server error, it will be retried for 24 hours until it gets a meaningful response
{% endhint %}

{% hint style="warning" %}
If the new status (in request) is the same of the client system, no action need to be taken in client system and a 200 response must be returned.
{% endhint %}

{% hint style="danger" %}
"cancelling bet" request will be sent only for tickets with status "0" (in running). If the ticket status on client side is different from "0" please response with failiure "406" code. This means that a previous "Reopening concluded bet" message was sent and has not been processed
{% endhint %}

#### Example Request

```json
{
  "clientId": "xyzk",
  "userId": 123456,
  "transactionType": 1,
  "amount": 10.56,
  "ticket": {
    "id": 123456,
    "code": "abcd1234",
    "amount": 10.56,
    "isBonus": false,
    "isFreebet": false,
    "freebetId": 0
  },
  "code": 2021,
  "reason": "ticket_canceled"
}
```

#### Example Success Response

<mark style="color:green;">`Response code`</mark> 200

After the deposit amount is added to user balance and the ticket is setted to "canceled" in client system, a 200 success response should be returned.

```json
{    
    "status": "success",
    "balance": 140.85,
    "error_code": 0,
    "error_message": ""
}
```

#### Example Failure Response

<mark style="color:red;">`Response code`</mark> 406

If there is any error in client system, a 406 response cose should be returned

```json
{
    "status": "error",
    "balance": 140.85,
    "error_code": 2001,
    "error_message": "client error"
}
```
