# Bet Placement API

This endpoint allows clients to submit requests for placing bets. Clients must include all relevant information related to the bet, such as the type of bet, stake amount, and selection details.\
\
Endpoint: v1/bet/placement\
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": "3CB3CFB9-20AC-4AB5-BD15-67E5D78DD960",
  "userId": "123456",
  "stake": 5.0,
  "oddsType": 0,
  "oddsChangeType": 1,
  "currencyCode": "USD",
  "channel": 0,
  "betDate": "2024-03-11T05:41:31.451Z",
  "ipAddress": "192.168.1.1",
  "ipAddressV6": "::ffff:c0a8:101",
  "selections": [
    {
      "fixtureSpecifier": "sr:match:48588059",
      "marketSpecifier": "total=88.5",
      "marketTemplateId": "238",
      "selectionTemplateId": "12",
      "odds": 2.0
    }
  ]
}
```

Properties:

| Name           | Type             | Description                                                                                                                       |
| -------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| betId          | string           | Unique id of the bet                                                                                                              |
| userId         | string           | Unique id of the user                                                                                                             |
| stake          | decimal          | Amount the player placed on a bet                                                                                                 |
| oddsType       | int              | See [Odds Type](/odds-feed-documentation/placement-validation/dictionary.md#odds-type) for more details.                          |
| oddsChangeType | int              | See [Odds Change Type](/odds-feed-documentation/placement-validation/dictionary.md#odds-change-type) for more details.            |
| currencyCode   | string           | Currency the player is using                                                                                                      |
| channel        | int              | <p>Channel on where the bet was placed.<br><br>See <a href="/pages/tqn6WDrfPTTdUrZ6Y4o9#channel">Channel</a> for more details</p> |
| betDate        | datetime         | Date on when the bet was placed.                                                                                                  |
| ipAddress      | string           | IP Address of the player                                                                                                          |
| ipAddressV6    | string           | IP Address V6 of the player                                                                                                       |
| selections     | List\<Selection> | See [Selection Model](#bet-selection-request-model) for more details                                                              |

### Bet Selection Request Model

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

The request would go through a pre-validation process wherein it will check if the request is valid and correct. If valid, the API will return a successful payload response containing a betStatusId value of 1000 (Waiting).

The payload response will contain status of the bet including the odds and stakes in every selections:

```
{
    "statusCode": 100,
    "message": "Success",
    "result": {
        "generatedBetId": "BDEAE2E7-442E-4276-BCC6-08DCC741FD5E",
        "userId": "TSO-15678",
        "betId": "E9C8636F-0A0B-4D5C-95B6-16084C91A30C",
        "betStatusId": 1000,
        "betStatusName": "Waiting",
        "stake": 50.00,
        "totalOdds": 2.57,
        "betSelections": [
            {
                "statusCode": 100,
                "message": "Success",
                "fixtureSpecifier": "sr:match:52784995",
                "marketSpecifier": "",
                "marketTemplateId": "1",
                "selectionTemplateId": "1",
                "odds": 2.57
            }
        ]
    }
}
```

Properties

| Name       | Type       | Description                                                                                                   |
| ---------- | ---------- | ------------------------------------------------------------------------------------------------------------- |
| statusCode | int        | [Status code](/odds-feed-documentation/placement-validation/dictionary.md#status-code) of the payload request |
| message    | string     | Reason why the request was rejected.                                                                          |
| result     | List\<Bet> | See [Bet Model](#bet-response-model) for more details                                                         |

### Bet Response Model

| Name           | Type                | Description                                                                                                                                    |
| -------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| userId         | string              | Unique id of the user                                                                                                                          |
| 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> |
| betId          | string              | Unique id of the bet                                                                                                                           |
| betStatusId    | int                 | See [Bet Status](/odds-feed-documentation/placement-validation/dictionary.md#bet-status) for more details.                                     |
| betStatusName  | string              | See [Bet Status](/odds-feed-documentation/placement-validation/dictionary.md#bet-status) for more details.                                     |
| stake          | decimal             | Amount the player placed on a bet                                                                                                              |
| betSelections  | List\<BetSelection> | See [Selection Model](#bet-selection-response-model) for more details                                                                          |

### Bet Selection Response Model

| Name                | Type    | Description                                                                                                                                                                |
| ------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| statusCode          | int     | <p>Determines if the selection is valid or not<br><br>See <a href="/pages/tqn6WDrfPTTdUrZ6Y4o9#status-code">Status Code</a> for more details</p>                           |
| message             | string  | <p>Show the reason the message is invalid or shows a successful message.<br><br>See <a href="/pages/tqn6WDrfPTTdUrZ6Y4o9#status-code">Status Code</a> for more details</p> |
| fixtureSpecifier    | string  | Unique id of the fixture                                                                                                                                                   |
| marketSpecifier     | string  | Unique market specifier                                                                                                                                                    |
| marketTemplateId    | string  | Template id of the market                                                                                                                                                  |
| selectionTemplateId | string  | Template id of the selection                                                                                                                                               |
| odds                | decimal | Odds on when the bet was placed                                                                                                                                            |

### Callback

Once the bet placement 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.

* Running status: if the request is accepted and processed successfully, the callback response will include a status of "Running". This indicates that the bet placement or cashout request has been successfully executed.
* Rejected status: if the request is rejected due to validation errors or other issues, the callback response will include a status of "Rejected". This indicates that the bet placement or cashout request could not be processed as requested.

### Callback URL Setup&#x20;

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

Endpoint: /bet/status/placement\
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": 2000,
    "betStatusName": "Running",
    "reason": "1024 - Ticket accepted (MTS)",
    "action": "PLACEBET",
    "timestamp": "2024-08-28T09:55:37.2566921Z",
    "betSelections": [
        {
            "marketTemplateId": "223",
            "selectionTemplateId": "1714",
            "odds": 1.78,
            "fixtureSpecifier": "sr:match:52861055",
            "marketSpecifier": "hcp=4.5"
        }
    ]
}
```

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 [Bet Status](/odds-feed-documentation/placement-validation/dictionary.md#bet-status) for more details.                                     |
| betStatusName  | string                     | See [Bet Status](/odds-feed-documentation/placement-validation/dictionary.md#bet-status) for more details.                                     |
| reason         | string                     | Reason why the bet was accepted or rejected.                                                                                                   |
| action         | string                     | for the Bet Placement validation, the value would always be "PLACEBET".                                                                        |
| timestamp      | datetime                   | Timestamp on when the bet was accepted or rejected.                                                                                            |
| betSelections  | List\<BetSelectionRequest> | See [SelectionRequest Model](#bet-selection-request-model-1)  for more details                                                                 |

### Bet Selection Request 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               | <p>Indicates the status of the request<br><br>1000 - Success</p> |
| message  | string (optional) | status message                                                   |

Code: *Bad Request (400)*

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

Properties

| Name     | Type   | Description                                                                    |
| -------- | ------ | ------------------------------------------------------------------------------ |
| statusId | int    | <p>Indicates the status of the request<br><br>1003 - Internal Server Error</p> |
| 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/placement-validation/bet-placement-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.
