Dry-run a threshold change against recent sessions
const url = 'http://localhost:8000/api/thresholds/preview/';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"activity":"running","exercise":"Treadmill","metric_key":"cadence","min_good":178,"max_good":184,"session_window_days":30}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://localhost:8000/api/thresholds/preview/ \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "activity": "running", "exercise": "Treadmill", "metric_key": "cadence", "min_good": 178, "max_good": 184, "session_window_days": 30 }'Any team member; read-only. Replays a proposed (min_good, max_good) band over the team’s recent session window (default 30 days, configurable via session_window_days) and reports which sessions would flip in/out of the green zone — without persisting anything. No DB write, no audit row. Backs the “Preview impact” affordance on the editor row before the coach commits the save.
flipped_session_count / flipped_client_count are the uncapped totals behind the two flip lists (which stop at 10 each).
client_group (#2518) dry-runs a client group’s own range: only the group’s members’ sessions are evaluated — “N sessions of M clients in this group change zone”. Each session counts against the band its member reads today, at the threshold-row tier (before the in-code gender / height layers): the group’s own row when one covers the edited level (an exercise-level edit: its row at that exercise or its activity row; an activity-level edit: only its activity row); otherwise the member’s own band, resolved per exercise — their cohort row, or the row of a lower-priority group that already ranges the metric — once per distinct member slice; no row means unconstrained. Left out, because the edit would not move their zone: a member whose higher-priority group sets its own range for the metric, and, on an activity-level edit, a session at an exercise the group already ranges more specifically. Same 400s as the create path.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
running- Runningwalking- Walkingjump- Vertical Jumpweightlifting- Weightliftingmobility- Mobility Assessmentworkspace_wellness- Workspace Wellnessagility- Agilityfencing- Fencingcycling- Cyclingtennis- Tennispadel- Padel Tennisbowling- Bowlingbaseball- Baseballfootball- Footballbadminton- Badmintoncricket- Cricketbasketball- Basketballscuba_diving- Scuba Divingice_hockey- Ice Hockeyamerican_football- American Footballfri- Falls Risk Indicatorpickleball- Pickleball
Dry-run this client group’s own range (#2518): only the group’s members’ sessions are evaluated. Same 400s as the create path.
Examples
Dry-run a new band
{ "activity": "running", "exercise": "Treadmill", "metric_key": "cadence", "min_good": 178, "max_good": 184, "session_window_days": 30}Dry-run a client group's range
{ "activity": "running", "exercise": "Treadmill", "metric_key": "cadence", "client_group": "b3f1c0a2-0000-4000-8000-000000000001", "min_good": 170, "max_good": 190, "session_window_days": 30}object
running- Runningwalking- Walkingjump- Vertical Jumpweightlifting- Weightliftingmobility- Mobility Assessmentworkspace_wellness- Workspace Wellnessagility- Agilityfencing- Fencingcycling- Cyclingtennis- Tennispadel- Padel Tennisbowling- Bowlingbaseball- Baseballfootball- Footballbadminton- Badmintoncricket- Cricketbasketball- Basketballscuba_diving- Scuba Divingice_hockey- Ice Hockeyamerican_football- American Footballfri- Falls Risk Indicatorpickleball- Pickleball
Dry-run this client group’s own range (#2518): only the group’s members’ sessions are evaluated. Same 400s as the create path.
object
running- Runningwalking- Walkingjump- Vertical Jumpweightlifting- Weightliftingmobility- Mobility Assessmentworkspace_wellness- Workspace Wellnessagility- Agilityfencing- Fencingcycling- Cyclingtennis- Tennispadel- Padel Tennisbowling- Bowlingbaseball- Baseballfootball- Footballbadminton- Badmintoncricket- Cricketbasketball- Basketballscuba_diving- Scuba Divingice_hockey- Ice Hockeyamerican_football- American Footballfri- Falls Risk Indicatorpickleball- Pickleball
Dry-run this client group’s own range (#2518): only the group’s members’ sessions are evaluated. Same 400s as the create path.
Responses
Section titled “Responses”object
object
object
object
object
Sessions whose zone the change flips — the uncapped total behind the two lists above, which stop at 10 each (#2518).
Distinct clients those flipped sessions belong to (#2518).
Echo of the request’s client_group: the dry run evaluated that group’s members only. null for a cohort-slot preview.
Example generated
{ "total_evaluated": 1, "before": { "green_count": 1, "yellow_count": 1, "red_count": 1 }, "after": { "green_count": 1, "yellow_count": 1, "red_count": 1 }, "flipped_to_green": [ { "session_id": "example", "client_display_name": "example", "value": 1 } ], "flipped_to_red": [ { "session_id": "example", "client_display_name": "example", "value": 1 } ], "flipped_session_count": 1, "flipped_client_count": 1, "client_group": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "session_window_days": 1}object
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).
Example generated
{ "detail": "example"}object
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).
Example generated
{ "detail": "example"}object
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).
Example generated
{ "detail": "example"}