Skip to content

Public SSE stream of AI coaching for a shared session

GET
/api/shared/{token}/coaching/
curl --request GET \
--url http://localhost:8000/api/shared/example/coaching/

Public, token-gated SSE stream — same coaching analysis as the authenticated endpoint, but for a session that was shared via POST /api/sessions/<id>/share/. Anyone with the share URL already sees every metric on the report page; the AI paragraph is the same level of exposure. Same focus / lang / units query params as the authenticated stream. A single event: error frame with HTTP 404 is sent for an unknown token.

Auth: none — the token in the path is the credential.

  • None
token
required
string
focus
string

Optional metric/area to bias the analysis toward.

lang
string

en (default) or ru.

units
string

metric (default) or imperial.

A text/event-stream (SSE) response. Frames arrive as event: <name>\ndata: <json>\n\n: one meta prelude, a sequence of token frames each carrying {text}, then a final done {ok: true}. On error a single error frame {detail} is sent and the HTTP status is set to 404 (unknown session/token).

Media typeapplication/json
string
Examples
ExampleSSEFrameSequence(illustrative)

SSE frame sequence (illustrative)

Server-sent events; the actual response is text/event-stream. The example shows the concatenated frames as they arrive — meta first, a sequence of token, done last.

event: meta
data: {"session_id":"5c836d7d","activity":"running","client":"Anna Petrova","focus":null,"lang":"en","system":"metric","model":"","provider":"","mode":"live"}
event: token
data: {"text":"Cadence "}
event: token
data: {"text":"of "}
event: token
data: {"text":"169 spm "}
event: token
data: {"text":"is on the low side; "}
event: token
data: {"text":"target 175-180 for this pace.\n"}
event: done
data: {"ok":true}
Media typeapplication/json
object
detail
required

Human-readable message, or a stable machine code for the cases a client branches on. The standard envelope for 400 (validation — a field-keyed object may appear instead), 401 (missing / invalid credentials), 403 (authenticated but not permitted), and 404 (absent — cross-team records are collapsed to 404 so the API never leaks the existence of another team’s data).

string
Examplegenerated
{
"detail": "example"
}