Events
Set Websocket
Enables or disables the instance’s WebSocket and sets the event filter and base64 media
POST
Set Websocket
Auth:
Envelope:
TokenAccount or TokenInstance • Rate limit: Global (100/min) • Idempotent: yes (upsert)
Description
Enables / disables the instance’s WebSocket channel and sets the event filter. Unlike the webhook, there is a single configuration per instance (nolabel). This endpoint does not open a connection, it only authorizes the later upgrade at GET /ws/:instance.
Examples
Enable everything
Turns on the WebSocket without any filter: sinceevents is omitted, the client receives all 6 event types, and mediaBase64 stays false.
Narrow filter
Enables the WebSocket receiving onlymessage.exchange and message.status and turns on mediaBase64: true so frames with media already include the binary content base64-encoded.
Disable the websocket
Turns off the WebSocket by sendingenabled: false. The configuration row is preserved, events and mediaBase64 are cleared, and new connections to /ws/:instance start being rejected.
Success response
The response returns thewebsocket object with the configuration actually persisted (enabled, events, mediaBase64), mirrors the request body after the upsert. When enabled=false, events and mediaBase64 come back cleared; connections already open at /ws/:instance remain until closed naturally, but new connections start being rejected with 400.
200 OK
Path parameters
Instance name.
Headers
TokenAccount or TokenInstance.application/jsonRequest body
Turns the WebSocket on/off. When
false, events and mediaBase64 are cleared before saving.Filter. Empty array = receive all 6 types. Values must be in
{message.exchange, message.status, call.update, group.flow, instance.state, label.update}.When
true, message.exchange events with media include media.base64 in the WS frames.Notes
- Does not persist events: WebSocket is ephemeral. If no one is connected at the moment of the event, it’s discarded (fast-path
HasClientsbefore any serialization work). - No retry: if the socket drops during send, the message is lost. For guaranteed delivery, use webhook.
enabled=falsedoes not disconnect already-open clients: existing connections at/ws/:instanceremain until closed naturally; new connections fail with400.- No documented connection limit: each instance can have N simultaneous clients (broadcast). The hub keeps a 256-message buffer per client; slow clients are disconnected automatically.
- Configuration at creation time: the same block can be passed to
POST /api/instance/newviawebsocketEnabled,websocketEvents,websocketMediaBase64.
Errors
| HTTP | error.message |
|---|---|
| 400 | Invalid request body |
| 401 | Invalid token |
| 404 | Instance not found |
| 429 | Rate limit exceeded. Try again later. |
| 500 | Failed to get instance |
Next
Check WebSocket config
GET /api/events/getWebsocket/:instanceConnect via WebSocket
GET /ws/:instance, protocol, auth, reconnection.