Sessions API: group requests and read a session timeline
List recent sessions and read one session's ordered requests, grouped by the session id sent with each call, on an admin key or a console sign-in.
A session groups the requests that carry the same session id, and the sessions API at https://api.uplinkswitch.com/v1 lets you list recent ones and walk a single session's timeline. The requests and receipts reference covers one call in isolation; this page covers the thread of calls that belong together. Both routes want an admin key or a console sign-in, because a session spans the whole organization's traffic rather than one key's.
List recent sessions
GET /v1/sessions returns the organization's recent sessions, each summarizing the requests grouped under its session id. Filter by key_id, set days from 1 to 90 (default 30), and set limit from 1 to 200 (default 50). Continue with before set to the returned next_before while has_more is true. Rows include requests, models, key ids, input/output tokens, errors, cost and first/last activity in Unix milliseconds.
One session's timeline
GET /v1/sessions/{session_id} returns request metadata in start order, with token counts, cost, latency and outcome, rather than prompt and response bodies. Only the latest 1,000 requests are included; truncated signals an incomplete timeline. URL-encode the session id in the path. The session id is the value your application sends with each request to tie them together; a session that holds no request of your organization is reported as not found rather than as someone else's.
Example
curl https://api.uplinkswitch.com/v1/sessions/SESSION_ID \
-H "Authorization: Bearer sk-uplink-live-ADMIN..."The reply is the ordered timeline for that one session.
Status codes
Both routes return 200 on success. Without an admin key and without a console sign-in, the answer is 401 unauthorized. A session id with no request of your organization behind it is 404 not_found; it is never a window onto another organization's traffic.
How this relates to requests and exports
For a single call's cost and its signed receipt, use the requests and receipts reference. For the whole request log as a downloadable CSV, filtered by key, model, status or user, use the exports reference. Sessions sit between the two: coarser than one request, narrower than the full log, and keyed on the session id your client sets.