> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bringits.com/llms.txt
> Use this file to discover all available pages before exploring further.

# WebSocket Send

> Send a message over the active WebSocket connection

The WebSocket Send command (Command Type: 3) sends a message over the active WebSocket connection. Typically used inside `onConnect` or `onInterval` hooks of the WebSocket command.

## Command Type

**Command Type ID:** 3

## Parameters

| Parameter       | Type   | Description                                 | Required |
| --------------- | ------ | ------------------------------------------- | -------- |
| **sendMessage** | string | The message payload to send over the socket | Yes      |

## Message Format

`sendMessage` is always a **string**, sent over the socket as-is (a text frame). The feed decides what that string must contain:

* **JSON feeds:** pass the JSON already stringified (escape the inner quotes), e.g. `"{\"action\":\"subscribe\",\"channel\":\"live_odds\"}"`. Do not pass a JSON object — it must be a string.
* **Plain-text feeds:** pass the literal token the feed expects, e.g. `"ping"`.
* Placeholders (e.g. `${state.eventId}`) are resolved before the message is sent, so you can build the payload from earlier results.

This command must run inside an active WebSocket connection (typically an `onConnect`, `onInterval`, or `onMessage` hook); on its own, with no live socket, there is nothing to send.

## Usage Examples

### Send Subscription Message on Connect

Used inside the `onConnect` hook of a WebSocket command:

```json theme={null}
{
  "id": 3,
  "type": "WS",
  "params": {
    "sendMessage": "{\"action\":\"subscribe\",\"channel\":\"live_odds\"}"
  }
}
```

### Send Periodic Heartbeat

Used inside an `onInterval` hook:

```json theme={null}
{
  "id": 3,
  "type": "WS",
  "params": {
    "sendMessage": "{\"type\":\"heartbeat\"}"
  }
}
```

## Related Commands

* [WebSocket](/stream/commands/ws/websocket) - The parent command that provides the connection context
* [WebSocket Close](/stream/commands/ws/websocket-close) - Close the connection after sending
