Skip to content

Per-activity + needs-review counts for the journal chip row

GET
/api/sessions/counts/
curl --request GET \
--url http://localhost:8000/api/sessions/counts/ \
--header 'Authorization: Bearer <token>'

Returns the activity-chip counts shown on the sessions journal — per-activity totals plus the count of completed sessions awaiting coach review. With server-side pagination on GET /api/sessions/ (#364), the FE no longer holds the full dataset client-side and needs a dedicated cheap aggregate endpoint for chip badges. Two GROUP BY-style queries against the existing (activity, status) composite index — fast even on a clinic-scale team.

Filters mirror the list endpoint for the same axes (from/to/client/is_demo) so a coach narrowing the date window sees chip counts that match what’s in the list. DELIBERATELY ignored: activity (the dimension being counted; chip toggle would zero its own count), exercise, camera_view, search, sort, needs_review (a separate aggregate is returned). “What will I see if I click this chip?” — the chip toggles only the activity axis; everything else stays.

Auth: team-scoped — reachable with a partner aik_… API key as well as a user session.

client
string format: uuid

UUID of a Client to scope the counts to.

from
string

Range start (ISO YYYY-MM-DD, inclusive). Combined at the viewer’s tz start-of-day so the count window matches the coach’s calendar day, not the server’s UTC day (#707). Pairs with to.

is_demo
boolean

When true, counts the curated demo team’s sessions instead of the caller’s team.

to
string

Range end (ISO YYYY-MM-DD, inclusive). Combined at the viewer’s tz end-of-day. Pairs with from.

tz
string

Viewer’s IANA timezone (e.g. America/Chicago) used to combine from/to into local-day boundaries. Omit to fall back to UTC (legacy / partner-key callers).

Media typeapplication/json
object
activity_counts
required

Per-activity session count within the current from/to/client scope. Every member of the Activity enum is included — absent activities carry 0 so the FE chip row can render without a missing-key branch.

object
key
additional properties
integer
needs_review_count
required

Completed sessions in the same scope that do not yet have a coach_review metric. Drives the ‘Needs review (N)’ header badge on the journal.

integer
processing_count
required

Sessions still in the pipeline (pending + processing) in the same scope. One of the three inputs to the global notifications-bell badge.

integer
failed_count
required

Sessions whose pipeline ended in failed in the same scope. One of the three inputs to the global notifications-bell badge.

integer
Examplegenerated
{
"activity_counts": {
"additionalProperty": 1
},
"needs_review_count": 1,
"processing_count": 1,
"failed_count": 1
}
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"
}
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"
}