Palbase Realtime · API
/realtime/v1/websocketOpen the realtime socket
Opens the realtime socket: Phoenix Channels v2 frames, [join_ref, ref, topic, event, payload], the protocol the platform's web, iOS and Android SDKs speak. One socket carries every channel a client is on.
The socket belongs to the project its host names. A browser cannot set a header on a WebSocket handshake, so the project's publishable key, or a signed-in user's access token, travels in the apikey parameter (web) or the x-api-key header (iOS, Android); with neither, the socket still opens. Who the client is, is the access token each join presents (phx_join {access_token}); renewed in place with an access_token frame. A channel is joined only if the project declared it (PUT /realtime/channels) and the user may: an owner channel is the user's own, a public one any signed-in user's; roles:<ref>:<user_id> is the user's permission set, written by the platform.
Frames: broadcast (to every subscriber on every replica but the sender); a keyed state per channel, which the client writes with state_set / state_del and asks for whole again with state_resync, and the server sends as a state_snapshot on join and on resync, then as a state_diff (from_seq and seq, so a missed change shows) after it; ephemeral entries are the writer's presence, gone when it leaves; heartbeat every 25 seconds (a socket silent for 60 is closed); phx_leave. A refusal is a phx_reply error with its reason: unauthorized, forbidden, invalid_topic, rate_limited, too_many_channels, state_budget, log_budget, reply_too_large, unavailable. A member's message on a channel the project's machine serves (a gateway) is answered with the machine's ack: {reply} in the ok reply, when it gave one. A frame over 1 MiB closes the socket (1009); a replica restarting closes it with 1012, and the SDKs reconnect.
Delivered frames are metered (realtime.messages), and so are the connections a project holds at once (realtime.connections); a quota used up under its reject mode, or the project's connection limit, refuses a new socket with 429.
Called by .
Query
apikeystring · optionalThe project's publishable key, or the signed-in user's access token (a browser's way: it cannot set a header on the handshake).vsn"2.0.0" · optionalThe protocol version: 2.0.0.Headers
x-api-keystring · optionalThe project's publishable key, or the signed-in user's access token (iOS and Android).Upgrade"websocket" · requiredwebsocketcurl -X GET "https://<your-ref>.palbase.studio/realtime/v1/websocket"Responses
101The socket is open
401No key, or not a key of this project, or a token that is not valid (the edge's answer)
429The project's request rate, its realtime quota for the period, or the connections it allows are used up; Retry-After says when to try again
503The platform could not answer now; retrying is safe (Retry-After)
defaultAn error: the envelope names it (`error`) and explains it (`error_description`).
Operation OpenSocket of realtime's contract.