# Bet Cancellation API

This endpoint allows the client to submit requests for cancelling a list of bets. Client must include the id of the bet and the reason as to why the bet should be cancelled.

Endpoint: v1/bet/cancel\
Method: POST

Headers:

| Name        | Description                                                     |
| ----------- | --------------------------------------------------------------- |
| x-client-id | A static client id will be assigned to you upon request.        |
| x-api-key   | We will provide you with an api key to be able to call the API. |

The payload request should contain JSON data structured according to the API specifications. Here's an example of a payload request:

```
{
    "betId": "32C922B2D-7F97-4DB5-6203-08DCC7478FE2",
    "reason": "Discrepancy in the bet"
}
```

Properties:

| Name   | Type   | Description                                                     |
| ------ | ------ | --------------------------------------------------------------- |
| betId  | string | Unique id of the bet. Please provide here the generated Bet Id. |
| reason | string | Reason as to why the bet should be cancelled                    |

The request would go through a pre-validation process wherein it will check if the request is valid and correct.

```
{
    "statusCode": 100,
    "message": "Success",
    "result": {
        "isSuccess": true,
        "message": "Success",
        "betId": "58FBA577-0ACA-407D-ABF6-B5154CCBB689",
        "generatedBetId": "2C922B2D-7F97-4DB5-6203-08DCC7478FE2",
    }
}
```

Properties

| Name       | Type                                                  | Description                                                                                               |
| ---------- | ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| statusCode | int                                                   | [Status code](/odds-feed-documentation/bet-cancellation/dictionary.md#status-code) of the payload request |
| message    | string                                                | Reason why the request was rejected.                                                                      |
| result     | List<[BetCancelResponse](#bet-cancel-response-model)> | Result of the bet cancellation request                                                                    |

### Bet Cancel Response Model

| Name           | Type   | Description                                                                                   |
| -------------- | ------ | --------------------------------------------------------------------------------------------- |
| isSuccess      | bool   | Determines wether the bet passed the validation or not                                        |
| message        | string | Indicates if the message is successfully validated or states the reason as to why it  failed. |
| betId          | string | Provider's Unique id of the bet                                                               |
| generatedBetId | string | System generated unique id on our side                                                        |

### Callback

Once the bet cancellation request has been internally processed and is valid, the API sends a response to a callback URL provided by the client. This callback response contains information about the status of the request whether if the bet was cancelled successfully from our end or not.

### Callback URL Setup <a href="#callback-url-setup" id="callback-url-setup"></a>

To allow us to deliver data, you need to setup your own API endpoint that exposes the following route:

Endpoint: /bet/status/cancellation\
Method: POST

The payload request should contain JSON data structured according to the API specifications. Here's an example of a payload request:

```
{
    "generatedBetId": "2C922B2D-7F97-4DB5-6203-08DCC7478FE2",
    "betId": "7B337436-1A5F-42D7-0DBC-08DCC62915EA",
    "betStatusId": 7000,
    "betStatusName": "Cancelled",
    "action": "CANCELBET",
    "timestamp": "2024-08-28T09:55:39.4149433Z",
    "errorMessage": null,
    "betSelections": [
        {
            "marketTemplateId": "223",
            "selectionTemplateId": "1714",
            "odds": 1.78,
            "fixtureSpecifier": "sr:match:52861055",
            "marketSpecifier": "hcp=4.5",
            "selectionSpecifier": null
        }
    ]
}
```

Properties:

| Name           | Type                                                        | Description                                                                                                                                    |
| -------------- | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| betId          | string                                                      | Unique id of the bet                                                                                                                           |
| generatedBetId | string                                                      | <p>System generated unique id on our side. (will be used in searching in reports)<br><br>Only one generated bet id will be created per bet</p> |
| betStatusId    | int                                                         | See [BetStatus](/odds-feed-documentation/bet-cancellation/dictionary.md#bet-status) for more details                                           |
| betStatusName  | string                                                      | See [BetStatus](/odds-feed-documentation/bet-cancellation/dictionary.md#bet-status) for more details                                           |
| action         | string                                                      | For the bet cancellation, the value would always be "CANCELBET".                                                                               |
| errorMessage   | string                                                      | Indicates the error message if the bet didn't pass our service validation.                                                                     |
| betSelections  | List<[BetSelectionResponse](#bet-selection-response-model)> | See [Bet Selection Respons](#bet-selection-response-model)e for mroe details                                                                   |

### Bet Selection Response Model

| Name                | Type    | Description                       |
| ------------------- | ------- | --------------------------------- |
| marketTemplateId    | string  | Template id of the market         |
| selectionTemplateId | string  | Template id of the selection      |
| odds                | decimal | Odds on when the bet was accepted |
| fixtureSpecifier    | string  | Unique id of the fixture          |
| marketSpecifier     | string  | Unique id of the market           |
| selectionSpecifier  | string  | Unique id of the selection        |

Once we receive a response from your endpoint, the payload response should contain a JSON data structure as shown in below:

Code: *200 (OK)*

```
{
  "statusId": 1000,
  "message": "Success"
}
```

Properties:

| Name     | Type              | Description                                        |
| -------- | ----------------- | -------------------------------------------------- |
| statusId | int               | Indicates the status of the request 1000 - Success |
| message  | string (optional) | status message                                     |

Code: *Bad Request (400)*

```
{
  "statusId": 1003,
  "message": "Error encountered when cancelling a bet"
}
```

Properties

| Name     | Type   | Description                                                       |
| -------- | ------ | ----------------------------------------------------------------- |
| statusId | int    | Indicates the status of the request 1003 - Internal Server Error  |
| message  | string | status message (you can place here what is the error encountered) |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://flyingcockatoo.gitbook.io/odds-feed-documentation/bet-cancellation/bet-cancellation-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
