Endpoint

This endpoint upgrades to a WebSocket. Start a session with a viewId, then attach this connection to the returned session. It keeps that view alive without background JavaScript timers. It carries presence only; use the existing live stream for video and controls.

First Message

Send a JSON attachment within five seconds of opening the socket. Credentials belong in this message, never in the URL.
string
required
Must be attach.
string
required
Your API key or login access token, without the Bearer prefix.
string
required
The phone opened by this view.
string
required
The UUID used in Start Sessions for this view.
string
required
The exact session ID returned by Start Sessions.
string
Optional organization selector, with the same membership rules as X-Phonesinc-Organization on HTTP requests. The client carries its configured selector into this attachment.
The server answers with { "type": "ready" } after authentication and ownership checks. A refusal sends { "type": "error", "message": "..." } and closes the connection. Wait for ready before treating the view as connected. Authorization is rechecked during the connection; reconnect with a fresh token when necessary.

Closing and Reconnecting

Closing this socket allows 12 seconds for reconnection before the view becomes eligible for cleanup. The server checks expired holds every five seconds. If a browser or hub disappears without a clean disconnect, its persisted hold expires within 60 seconds of its last renewal and is then eligible for cleanup. A tab closed while its initial start request is still pending also uses the 60-second lease bound, because no socket has attached yet. Network teardown can add to the time until another session is ready. Native WebSocket ping/pong keeps healthy background tabs alive. A new connection for the same view supersedes the old connection; a delayed disconnect from the old socket cannot release the replacement. Other views and persistent API holds remain intact. The view-close endpoint releases one view explicitly without the reconnection grace. End Sessions ends the entire reservation.

Client