Socket handshake ticket
Auth
Socket handshake ticket
Issue a one-shot 60-second Redis ticket for the WebSocket handshake.
POST
Socket handshake ticket
Overview
Mints a short-lived, one-shot ticket the client uses to authenticate the WebSocket handshake. The pattern exists because Socket.IO does not carry anAuthorization header reliably and passing a JWT in the query string leaks it into access logs.
Flow:
- The authenticated client calls this endpoint over REST and receives
{ ticket: "..." }. - The client connects to the WebSocket with
?ticket=<ticket>in the handshake URL. - The realtime server atomically
GETDELs the ticket from Redis — exactly one admission per ticket.
Authentication
Bearer <accessToken> required. Scope: user.
Path parameters
None.Query parameters
None.Request body
None.Response — 200 OK
| Field | Type | Notes | Example |
|---|---|---|---|
ticket | string | One-shot Redis ticket. Pass as ?ticket=<value> on the WebSocket handshake URL. 60-second TTL. | tk_eJp8nWv2sR4uT6xV9yY0bN3mK5jL6hG7fD3eA0c-aR4 |
Example response
Error responses
| Status | Code | Meaning |
|---|---|---|
| 401 | UNAUTHENTICATED | Missing, malformed, or expired access token. |
| 503 | SERVICE_UNAVAILABLE | Redis is not configured in this environment (dev-only). |
Example error — 503
Side effects
- Writes a key
socket:ticket:<ticket>to Redis with the user id as the value and a 60-second TTL. - The key is deleted atomically by the realtime server when the socket connects (
GETDEL). After 60 seconds Redis evicts it automatically.
See also
- Authentication — full token lifecycle, including socket handshake.
- Login — issues the access token used here.