Subscribe to a thread's new messages in realtime (WebSocket)
Opens a WebSocket connection that streams a conversation’s new messages to you live, with no polling. As soon as either side posts a message, every connected subscriber of that thread receives it.
This is a WebSocket upgrade, not a normal request — send the standard upgrade headers
(Upgrade: websocket). The connection is served on the API’s own domain; the server responds
101 Switching Protocols and then pushes one JSON frame per new message:
{ "type": "message.created", "payload": { "thread_id": "…", "message": { … } } }
Authentication. Because a browser WebSocket cannot set request headers, supply the
credentials as query parameters on the connection URL (they may also be sent as headers
from non-browser clients):
api_key— your publishable key (a publishable key is fine; this is a browser-origin read).- one customer credential, proving the caller owns the thread:
auth_token— the session token of a customer signed in through Galactic Core (equivalently thex-auth-tokenheader),external_auth— a signed identity assertion for a customer authenticated with your own identity provider (equivalently thex-external-authheader), oridp_token— a raw token from your own identity provider that Galactic Core forwards to the store’s Auth verifier to validate (equivalently thex-idp-tokenheader).
The server validates the credential and confirms the customer is the thread’s participant
before accepting the socket; an unauthorized or non-participant connection is closed. Use the
subscribeToThread helper in the SDK to manage the connection (it returns an unsubscribe
function), or open the WebSocket yourself.
Send the text frame ping at intervals to keep an idle connection alive; the server replies
pong.
Authorizations
API Key Authentication
Use your API key in the Authorization header:
Key Types:
Secret Keys (Server-Side Only):
- Format:
tybrite_sk_live_*(production) ortybrite_sk_test_*(sandbox) - Full read/write access to all endpoints
- ⚠️ NEVER expose in client-side code or public repositories
- Required for: write operations, authentication, payment verification, AI recommendations
Publishable Keys (Client-Safe):
- Format:
tybrite_pk_live_*(production) ortybrite_pk_test_*(sandbox) - Read-only access (GET requests only, plus POST semantic search)
- ✅ Safe for client-side JavaScript, mobile apps, and public code
- Allowed for: browsing products, search, CMS content, pricing queries
Endpoint-Specific Requirements:
- Authentication endpoints (
/v1/auth/*): Secret key required - Payment verification (
POST /v1/payments/verify): Secret key required - AI Recommendations (
POST /v1/recommendations): Secret key required - Semantic Search (
POST /v1/search): Both key types allowed (read-only operation) - All write operations: Secret key required
- All read operations: Both key types allowed
Using a publishable key for restricted operations returns 403 Forbidden.
Headers
Header form of auth_token, for non-browser clients that can set request headers on the handshake.
Header form of external_auth.
Header form of idp_token.
Path Parameters
The conversation to receive realtime messages for.
Query Parameters
Your publishable key, supplied as a query parameter for the WebSocket handshake (browsers
cannot set the Authorization header on a WebSocket). May also be sent as the
Authorization: Bearer header from non-browser clients.
Session token of a customer signed in through Galactic Core. Supply this (or
external_auth) to authorize the subscription. May also be sent as the x-auth-token header.
Signed identity assertion for a customer authenticated with your own identity provider.
Supply exactly one customer credential (auth_token, external_auth, or idp_token) to
authorize the subscription. May also be sent as the x-external-auth header.
A raw token from your own identity provider (e.g. a Firebase ID token). Galactic Core
forwards it to the store's configured Auth verifier, which validates it and returns the
identity. Fail-closed: if the verifier rejects the token or is unreachable, the connection
is not authorized. Supply exactly one customer credential (auth_token, external_auth, or
idp_token). May also be sent as the x-idp-token header.
Response
Switching Protocols — the WebSocket is established. New-message frames follow on the socket.

