> 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-git-docs-agent-wallet-s-66054a-consensys-ddffed67.vercel.app/snaps/reference/snaps-api/snap%5Fopenwebsocket/)method.

## 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

null

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

## Example

**Manifest**

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

```

**Usage**

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

```
