> For the complete documentation index, see [llms.txt](/llms.txt).

- Snap

# snap_sendWebSocketMessage

Send a message to an open WebSocket connection. The message will be sent to the WebSocket connection with the specified ID, which must have been previously opened by the Snap using the [snap_openWebSocket](https://metamask-docs-f8nytczy3-consensys-ddffed67.vercel.app/snaps/reference/snaps-api/snap%5Fopenwebsocket/)method.

## Parameters[​](#parameters "Direct link to Parameters")

object

required

An object describing the WebSocket message to send.

### id

string

required

The ID of the WebSocket connection to send a message to.

### message

union

required

The message to send. This can be either a string or an array of numbers representing binary data.

### Options

string

or

number[]

## Returns[​](#returns "Direct link to Returns")

null

This method does not return any data, so the result is always `null`.

## Example

- Manifest
- Usage

```
{
  "initialPermissions": {
    "endowment:network-access": {}
  }
}

```

```
await wallet.request({
  method: 'snap_sendWebSocketMessage',
  params: {
    id: 'websocket-connection-id',
    message: 'Hello, WebSocket!', // or message: [1, 2, 3] for binary data
  },
})

```
