> For the complete documentation index, see [llms.txt](https://docs.lsports.eu/u/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lsports.eu/u/defend/websocket-connection.md).

# WebSocket Connection

Connect to the DEFEND WebSocket connection to receive real-time bet approval updates via secure WebSocket.

## Overview

The DEFEND WebSocket connection provides real-time event streaming via secure WebSocket connections. Clients receive instant updates for betting approval operations without needing to poll the API.

Bet approval operations occur on bet slips that reach the **Bet Referral** page and are manually approved or rejected by your team.

**Key Features:**

* Secure WebSocket (WSS) connections
* Real-time message broadcasting
* Customer-platform isolated rooms
* Support for multiple event types

**Supported Events:**

| Event                | Description                                                                                       |
| -------------------- | ------------------------------------------------------------------------------------------------- |
| `RESERVE_BET_ACCEPT` | A trader accepted a bet slip that was under review                                                |
| `RESERVE_BET_REJECT` | A bet slip that was under review was rejected, by a trader or because the decision window expired |

***

## Event Payloads

DEFEND sends `RESERVE_BET_ACCEPT` when a trader accepts a bet slip in [Bet Referral](https://docs.lsports.eu/u/defend/bet-monitor.md#bet-referral), and `RESERVE_BET_REJECT` when a trader rejects one or when its [60-second decision window](https://docs.lsports.eu/u/defend/bet-monitor.md#how-referral-decisions-work) expires. Both rejects use the same event and payload, so your sportsbook cannot tell them apart. These are the only two events for referral decisions.

The event data is a flat JSON object with no nested `data` field. Match each event to your bet slip using `code`.

| Field         | Type   | Required      | Events                    | Description                                                                                  |
| ------------- | ------ | ------------- | ------------------------- | -------------------------------------------------------------------------------------------- |
| **`code`**    | string | Yes           | Both                      | DEFEND bet slip code. Same value as `bet_code` in the placement response                     |
| **`betCode`** | string | Yes on accept | `RESERVE_BET_ACCEPT` only | Short bet slip code. Same value as `shortCode` in the placement response. Not sent on reject |
| **`user_id`** | string | No            | Both                      | The player ID you sent at placement. Omitted when the bet slip has none                      |

**RESERVE\_BET\_ACCEPT**

```json
{ "code": "croaw8qwu-h2js2j1b2d3", "betCode": "26419", "user_id": "10045" }
```

**RESERVE\_BET\_REJECT**

```json
{ "code": "croaw8qwu-h2js2j1b2d3", "user_id": "10045" }
```

Events do not include a rejection reason, stake or odds. An accepted bet slip keeps the stake and odds it was placed with.

***

## Delivery

DEFEND sends each event once, to connections that have joined their room. Events are not stored or resent.

* **Missed events:** If your connection is down when a trader decides, you do not receive that event. After you reconnect, check each bet slip still under review with [`POST /bet/detail`](https://docs.lsports.eu/u/defend/api.md).
* **Timing:** Events usually arrive within a few seconds of the trader's decision

***

## Connection Requirements

### Endpoint

| Environment | URL                    |
| ----------- | ---------------------- |
| Production  | `wss://rms.lsports.eu` |

**Path:** `/rms-socket/socket.io`

### Required Headers

| Header          | Type   | Required | Description                                                       |
| --------------- | ------ | -------- | ----------------------------------------------------------------- |
| `Authorization` | String | Yes      | Bearer token from ARENA360 authentication: `Bearer <accessToken>` |
| `customerid`    | String | Yes      | Your numeric Customer ID                                          |

> Refer to the [Authentication Guide](https://docs.lsports.eu/u/defend/integration-guide/authentication.md) for obtaining access tokens.

***

## Authentication

Before establishing a WebSocket connection, you must obtain a valid access token using your ARENA360 API credentials.

Refer to the [Authentication Guide](https://docs.lsports.eu/u/defend/integration-guide/authentication.md) for steps on:

1. Generating API tokens in ARENA360
2. Exchanging credentials for access tokens
3. Refreshing expired tokens

**Important Notes:**

* Access tokens expire every **30 minutes**
* Refresh tokens are valid for **7 days**
* Include the access token in the `Authorization` header as: `Bearer <accessToken>`

***

## Rate Limiting

| Limit Type            | Threshold      | Window                |
| --------------------- | -------------- | --------------------- |
| WebSocket Connections | 10 connections | Per minute per IP     |
| HTTP Requests         | 100 requests   | Per 15 minutes per IP |

Exceeding these limits will result in a `429 Too Many Requests` error.

***

## Next Steps

* [Quick Start & Best Practices](https://docs.lsports.eu/u/defend/websocket-connection/quick-start-and-best-practices.md) — Get connected in minutes
* [Code Examples](https://docs.lsports.eu/u/defend/websocket-connection/code-examples.md) — Complete examples in JavaScript, Python, and Browser
* [Error Handling](https://docs.lsports.eu/u/defend/websocket-connection/error-handling.md) — Error codes and troubleshooting guide


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.lsports.eu/u/defend/websocket-connection.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
