Skip to main content
The organization API is in early access and is not yet available to every organization. Live sessions are currently enabled in staging and gated behind early access in production.
A live session lets your app stream readings over a WebSocket while a teammate trains. The live gateway acknowledges each numbered batch, emits live cues as thresholds are crossed, and lets a dropped client resume where it left off. When the session ends, TechnicallyFit folds the session’s readings once into summaries and stores them through the same ingestion path as Sending events.
  • Authentication: Connect to wss://<host>/v1/live with an organization key (X-API-Key) or a teammate token (Authorization: Bearer <token>) carrying the events:write scope.
  • Consent: Before a teammate claims their account, live sessions are always accepted. After the claim, the teammate must allow the events consent item.
  • One ingestion path: A live session does not write raw samples to the teammate’s history. When you close the session, the folded summaries enter through the same consent, route limit, and duplicate checks as POST /v1/teammates/{external_id}/events.
Set these two values once in your terminal. Every example in these docs reads them, so no example has a host or a key typed into it.
Use a test key (it starts with tf_test_) while you build. Never paste a live key into a page, a ticket or a chat.

Opening and streaming a session

Open a session for one teammate, send live readings in numbered batches, listen for live cues, and close the session when the workout finishes. Both published SDKs provide a live helper (openLiveSession in @technicallyfit/sdk and open_live_session in technicallyfit[live]).

Wire protocol

Every message on /v1/live is a JSON object with a type field.

1. Open a session

Send session.open after the WebSocket connects. Pass an optional idempotency_key if your client may retry opening the same session.
Client -> Server
Server -> Client

2. Stream numbered batches and acknowledgements

Send readings in readings.batch frames with a monotonically increasing seq starting at 1. The gateway acknowledges each batch with readings.ack. If you resend a batch whose seq was already acknowledged, the gateway acknowledges it again without double-counting its readings.
Client -> Server
Server -> Client

3. Live cues

While readings arrive, the gateway tracks session summaries (such as a mean, a peak, or velocity loss within a set) and evaluates live cue rules. When a cue fires, the gateway sends a cue.emitted frame. Each cue respects a cooldown window so the same cue does not repeat on every rep, even if the client disconnects and resumes.
Server -> Client

4. Resuming after a drop

If the network drops or a server restarts during a deploy, reconnect to /v1/live and send session.resume with the session_id and your last_acked_seq. The gateway restores your session checkpoint and cue cooldowns, replies with session.opened ("resumed": true), and you continue from last_acked_seq + 1.
Client -> Server
Server -> Client

5. Closing and the close answer

Send session.end when the workout finishes. The gateway folds the session’s readings once into summaries and writes them through the events ingestion path. The session.ended frame returns one result per folded observation, using the same accepted, duplicate, and rejected statuses as Sending events.
Client -> Server
Server -> Client

Limits and errors

Every refusal or error arrives as a session.error frame with a stable code, a plain sentence message, and a retryable flag.
Server -> Client
See Rate limits and Plans for the default live session limits and how organization contracts configure them.