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

# Insurance

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

When the system creates a cashback from an insured bet, a request will be sent to the client system with the insurance cashback value and the date of insurance.

The received request contain a deposit amount. In this case the amount should be added to user balance.

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

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

#### Example request

```json
{
  "clientId": "xyzk",
  "userId": 123456,
  "transactionType": 1,
  "amount": 10.56,
  "ticket": {
    "id": 123456,
    "code": "abcd1234",
    "amount": 10.56,
    "insuranceCashback": 5.60,    
    "insuranceDate": "2024-05-03T23:45:00Z",
    "status": 1
  }
}
```

#### Example Success Response

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

If the request is successfully pocessed in client system and the deposit amount (if present) was added to user balance, a 200 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"
}
```
