@trainheroic-unofficial/cli 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -717,7 +717,7 @@ async function getJson(client, path, label) {
717
717
  if (!res.ok) throw new Error(`${label} failed (HTTP ${res.status}).`);
718
718
  return res.data;
719
719
  }
720
- async function getArray(client, path, label) {
720
+ async function getArray$1(client, path, label) {
721
721
  const res = await client.request("GET", path);
722
722
  if (!res.ok || !Array.isArray(res.data)) throw new Error(`${label} failed (HTTP ${res.status}).`);
723
723
  return res.data;
@@ -800,10 +800,10 @@ function fetchAthletePrefs(client) {
800
800
  return getJson(client, "/1.0/athlete/prefs", "athlete prefs");
801
801
  }
802
802
  function fetchWorkingMaxes(client) {
803
- return getArray(client, "/2.0/athlete/workingMax", "athlete working maxes");
803
+ return getArray$1(client, "/2.0/athlete/workingMax", "athlete working maxes");
804
804
  }
805
805
  function fetchExerciseHistoryList(client) {
806
- return getArray(client, "/v5/users/exercises/history", "athlete exercise history list");
806
+ return getArray$1(client, "/v5/users/exercises/history", "athlete exercise history list");
807
807
  }
808
808
  /** Free-text search over the athlete's logged exercises (FTS replacement via rankSearch). */
809
809
  async function searchExerciseHistory(client, query, limit = 20) {
@@ -813,7 +813,7 @@ function fetchExerciseHistoryDetail(client, exerciseId, userId) {
813
813
  return getJson(client, `/v5/exercises/${exerciseId}/history?userId=${userId}`, "athlete exercise history");
814
814
  }
815
815
  function fetchPersonalRecords(client, exerciseId) {
816
- return getArray(client, `/v5/exercises/${exerciseId}/personalRecords`, "athlete personal records");
816
+ return getArray$1(client, `/v5/exercises/${exerciseId}/personalRecords`, "athlete personal records");
817
817
  }
818
818
  /** Last performance + PR for an exercise. `date` (YYYY-MM-DD) is required by the API. */
819
819
  function fetchExerciseStats(client, exerciseId, userId, date) {
@@ -821,7 +821,7 @@ function fetchExerciseStats(client, exerciseId, userId, date) {
821
821
  }
822
822
  /** Scheduled + completed workouts in an inclusive YYYY-MM-DD window. */
823
823
  function fetchAthleteWorkouts(client, startDate, endDate) {
824
- return getArray(client, `/3.0/athlete/programworkout/range?startDate=${startDate}&endDate=${endDate}`, "athlete workouts");
824
+ return getArray$1(client, `/3.0/athlete/programworkout/range?startDate=${startDate}&endDate=${endDate}`, "athlete workouts");
825
825
  }
826
826
  /** Add `days` to a `YYYY-MM-DD` date (UTC), returning `YYYY-MM-DD`. */
827
827
  function shiftDate(iso, days) {
@@ -883,24 +883,6 @@ async function fetchAthleteWorkoutsChunked(client, startDate, endDate, opts = {}
883
883
  return page;
884
884
  }));
885
885
  }
886
- /**
887
- * A coach's view of a roster athlete's scheduled + completed workouts in an inclusive
888
- * YYYY-MM-DD window (`/3.0/coach/athlete/programworkout/range/{athleteId}`). Returns the same
889
- * `ProgramWorkout[]` shape as `fetchAthleteWorkouts`, so the same presenters and
890
- * `findSavedWorkoutSet` apply — it just reads another athlete's data through the coach surface.
891
- */
892
- function fetchCoachAthleteWorkouts(client, athleteId, startDate, endDate) {
893
- return getArray(client, `/3.0/coach/athlete/programworkout/range/${athleteId}?startDate=${startDate}&endDate=${endDate}`, "coach athlete workouts");
894
- }
895
- /**
896
- * A coach's month view of a roster athlete's logged sessions
897
- * (`/2.0/coach/athlete/calendar/summary`). The trailing path segment is required by the API but
898
- * ignored (any value returns the whole month); it mirrors the coach web app, which sends 7. The
899
- * `userId` in each row is the roster athlete, not the calling coach.
900
- */
901
- function fetchCoachAthleteCalendarSummary(client, athleteId, year, month) {
902
- return getArray(client, `/2.0/coach/athlete/calendar/summary/${athleteId}/${year}/${month}/7`, "coach athlete calendar summary");
903
- }
904
886
  function fetchLeaderboard(client, workoutId, opts = {}) {
905
887
  const qs = new URLSearchParams();
906
888
  if (opts.page !== void 0) qs.set("page", String(opts.page));
@@ -1365,6 +1347,70 @@ function presentExerciseHistory(detail) {
1365
1347
  };
1366
1348
  }
1367
1349
  //#endregion
1350
+ //#region ../js/src/coach-athlete-calendar.ts
1351
+ async function getArray(client, path, label) {
1352
+ const res = await client.request("GET", path);
1353
+ if (!res.ok || !Array.isArray(res.data)) throw new Error(`${label} failed (HTTP ${res.status}).`);
1354
+ return res.data;
1355
+ }
1356
+ /**
1357
+ * A coach's view of a roster athlete's scheduled + completed workouts in an inclusive
1358
+ * YYYY-MM-DD window (`/3.0/coach/athlete/programworkout/range/{athleteId}`). Returns the same
1359
+ * `ProgramWorkout[]` shape as `fetchAthleteWorkouts`, so the same presenters and
1360
+ * `findSavedWorkoutSet` apply — it just reads another athlete's data through the coach surface.
1361
+ */
1362
+ function fetchCoachAthleteWorkouts(client, athleteId, startDate, endDate) {
1363
+ return getArray(client, `/3.0/coach/athlete/programworkout/range/${athleteId}?startDate=${startDate}&endDate=${endDate}`, "coach athlete workouts");
1364
+ }
1365
+ /**
1366
+ * A coach's month view of a roster athlete's logged sessions
1367
+ * (`/2.0/coach/athlete/calendar/summary`). The trailing path segment is required by the API but
1368
+ * ignored (any value returns the whole month); it mirrors the coach web app, which sends 7. The
1369
+ * `userId` in each row is the roster athlete, not the calling coach.
1370
+ */
1371
+ function fetchCoachAthleteCalendarSummary(client, athleteId, year, month) {
1372
+ return getArray(client, `/2.0/coach/athlete/calendar/summary/${athleteId}/${year}/${month}/7`, "coach athlete calendar summary");
1373
+ }
1374
+ /**
1375
+ * Resolve a roster athlete's coach-writable calendar program id
1376
+ * (`GET /v5/calendars/athletes/{athleteId}?year=&month=`).
1377
+ *
1378
+ * Year and month are required by the API (HTTP 400 without them); the returned `programId` is
1379
+ * stable for the athlete, so any month works. This is the calendar the coach web app writes
1380
+ * with `createWorkoutForDay` when you open an athlete from My Athletes → calendar — distinct
1381
+ * from athlete-created `personal_cal` ad-hoc sessions.
1382
+ */
1383
+ async function fetchCoachAthleteCalendar(client, athleteId, year, month) {
1384
+ const path = `/v5/calendars/athletes/${athleteId}?year=${year}&month=${month}`;
1385
+ const res = await client.request("GET", path);
1386
+ if (!res.ok) {
1387
+ const detail = typeof res.data === "string" ? res.data : JSON.stringify(res.data);
1388
+ throw new Error(`GET ${path} failed (HTTP ${res.status}): ${detail}`);
1389
+ }
1390
+ if (!isRecord(res.data)) throw new Error("Unexpected athlete calendar response.");
1391
+ const programId = coerceInt(res.data.id);
1392
+ if (programId === null || programId <= 0) throw new Error(`Athlete calendar for ${athleteId} did not include a program id.`);
1393
+ return {
1394
+ programId,
1395
+ title: str$1(res.data.title) ?? "",
1396
+ type: coerceInt(res.data.type),
1397
+ groupId: coerceInt(res.data.group_id)
1398
+ };
1399
+ }
1400
+ /**
1401
+ * Resolve the calendar program id for `workout_build` / `coach workout build`: either an
1402
+ * explicit team/group `programId`, or a roster `athleteId` (+ date) via
1403
+ * `fetchCoachAthleteCalendar`. Exactly one of programId / athleteId is required.
1404
+ */
1405
+ async function resolveBuildProgramId(client, args) {
1406
+ if (args.programId !== void 0 && args.athleteId !== void 0) throw new Error("Pass programId or athleteId, not both.");
1407
+ if (args.programId !== void 0) return args.programId;
1408
+ if (args.athleteId === void 0) throw new Error("Provide programId (team calendar) or athleteId (athlete calendar).");
1409
+ if (args.date === void 0) throw new Error("athleteId requires date (YYYY-M-D) to resolve the athlete calendar.");
1410
+ const [y, m] = parseWorkoutDate(args.date);
1411
+ return (await fetchCoachAthleteCalendar(client, args.athleteId, y, m)).programId;
1412
+ }
1413
+ //#endregion
1368
1414
  //#region ../js/src/exercise-set-payload.ts
1369
1415
  function slotData(exercise, key) {
1370
1416
  const value = exercise?.[key];
@@ -2366,7 +2412,7 @@ async function collectAdvisories(blocks, index) {
2366
2412
  function calendarWriteError(method, path, status, detail) {
2367
2413
  const base = `${method} ${path} failed (HTTP ${status}): ${detail}`;
2368
2414
  if (!(path.includes("/createWorkoutForDay/") || path.includes("/createWorkoutForTimelineDay/") || path.includes("/copyProgramWorkout")) || status !== 500 && status !== 401) return new Error(base);
2369
- return /* @__PURE__ */ new Error(`${base}. This often means the program is another athlete's Coach Plan / personal calendar (personal_cal), which the coach calendar write endpoints do not support — workout_build and session_copy work on team/group programs (and the coach's own personal calendar), but there is currently no coach-facing tool to create sessions on another athlete's personal calendar.`);
2415
+ return /* @__PURE__ */ new Error(`${base}. This often means the programId is not a coach-writable calendar — use a team/group programId (list_teams → group_program) or resolve a roster athlete's calendar via GET /v5/calendars/athletes/{athleteId}?year=&month= (workout_build athleteId). Athlete-created personal_cal ad-hoc sessions are a different surface.`);
2370
2416
  }
2371
2417
  async function req(client, method, path, body) {
2372
2418
  const res = await client.request(method, path, body === void 0 ? void 0 : { body });
@@ -2553,6 +2599,36 @@ async function inviteAthletes(client, args) {
2553
2599
  };
2554
2600
  }
2555
2601
  /**
2602
+ * Update a team's title and/or reassign its calendar (`PUT /v5/teams/{teamId}`).
2603
+ *
2604
+ * The live API accepts `group_program` to point the team at an existing parent program /
2605
+ * calendar (e.g. another team's `group_program` from `list_teams`), but rejects a body that
2606
+ * has only `group_program` (HTTP 400 "Invalid parameters"). When `title` is omitted we read
2607
+ * the current title first so callers can re-link without renaming.
2608
+ */
2609
+ async function updateTeam(client, args) {
2610
+ if (args.title === void 0 && args.groupProgram === void 0) throw new Error("Provide title and/or groupProgram.");
2611
+ let title = args.title;
2612
+ if (title === void 0) {
2613
+ const existing = await client.request("GET", `/v5/teams/${args.teamId}`);
2614
+ if (!existing.ok) {
2615
+ const detail = typeof existing.data === "string" ? existing.data : JSON.stringify(existing.data);
2616
+ throw new Error(`GET /v5/teams/${args.teamId} failed (HTTP ${existing.status}): ${detail}`);
2617
+ }
2618
+ const rec = existing.data && typeof existing.data === "object" ? existing.data : null;
2619
+ title = typeof rec?.title === "string" ? rec.title : "";
2620
+ if (title.trim() === "") throw new Error(`Could not read current title for team ${args.teamId}; pass title explicitly.`);
2621
+ }
2622
+ const body = { title };
2623
+ if (args.groupProgram !== void 0) body.group_program = args.groupProgram;
2624
+ const res = await client.request("PUT", `/v5/teams/${args.teamId}`, { body });
2625
+ if (!res.ok) {
2626
+ const detail = typeof res.data === "string" ? res.data : JSON.stringify(res.data);
2627
+ throw new Error(`PUT /v5/teams/${args.teamId} failed (HTTP ${res.status}): ${detail}`);
2628
+ }
2629
+ return res.data;
2630
+ }
2631
+ /**
2556
2632
  * Copy/repeat a session to a target date on a program (`POST /2.0/coach/calendar/copyProgramWorkout`).
2557
2633
  * The API wants the target date as a structured object (with weekday and an isToday flag),
2558
2634
  * which is computed here from `toDate` (YYYY-M-D). Creates a new (unpublished) session.
@@ -3372,7 +3448,7 @@ Coach — manage a roster (needs a coach account):
3372
3448
 
3373
3449
  teams & join codes:
3374
3450
  coach team-create --title "..."
3375
- coach team-update --team <id> --title "..."
3451
+ coach team-update --team <id> [--title "..."] [--group-program <id>]
3376
3452
  coach team-delete --team <id> --yes
3377
3453
  coach team-code-create --team <id> [--type N]
3378
3454
  coach team-code-delete --code <id> --yes (--code is the id from team-code-create, not the join-code number)
@@ -3398,7 +3474,7 @@ Coach — manage a roster (needs a coach account):
3398
3474
 
3399
3475
  workouts (spec: {"blocks":[{"title","exercises":[{"id","sets"?,"reps"?,"weight"?,"rpe"?}]}],"instruction"?};
3400
3476
  reps/weight may be a scalar or per-set array; omit --publish to leave a draft):
3401
- coach workout build --program <id> (--date Y-M-D | --timeline-day <n>) [--publish --yes] <spec.json>|--file f
3477
+ coach workout build (--program <id> | --athlete <id>) (--date Y-M-D | --timeline-day <n>) [--publish --yes] <spec.json>|--file f
3402
3478
  coach workout read --program <id> --date Y-M-D --pw <id>
3403
3479
  coach workout publish --pw <id> --yes
3404
3480
  coach workout remove --program <id> --pw <id> --yes
@@ -3545,42 +3621,57 @@ async function cmdExercise(client, rest) {
3545
3621
  default: return fail("usage: trainheroic coach exercise <resolve|search|get|sync|create|forget|stats>");
3546
3622
  }
3547
3623
  }
3624
+ async function cmdWorkoutBuild(client, a) {
3625
+ const { values, positionals } = parse(a, {
3626
+ program: { type: "string" },
3627
+ athlete: { type: "string" },
3628
+ date: { type: "string" },
3629
+ "timeline-day": { type: "string" },
3630
+ publish: { type: "boolean" },
3631
+ yes: { type: "boolean" },
3632
+ file: { type: "string" }
3633
+ });
3634
+ const usage = "coach workout build (--program <id> | --athlete <id>) (--date Y-M-D | --timeline-day <n>) ...";
3635
+ const programRaw = values.program;
3636
+ const athleteRaw = values.athlete;
3637
+ if (values.date === void 0 && values["timeline-day"] === void 0) fail("provide --date YYYY-M-D or --timeline-day <n>.");
3638
+ let programId;
3639
+ try {
3640
+ programId = await resolveBuildProgramId(client, {
3641
+ ...programRaw !== void 0 ? { programId: toInt(programRaw, "--program") } : {},
3642
+ ...athleteRaw !== void 0 ? { athleteId: toInt(athleteRaw, "--athlete") } : {},
3643
+ ...values.date !== void 0 ? { date: values.date } : {}
3644
+ });
3645
+ } catch (err) {
3646
+ fail(err instanceof Error ? `${usage}: ${err.message}` : String(err));
3647
+ }
3648
+ const parsed = await jsonInput(positionals[0], values.file);
3649
+ const spec = validate(workoutSpecSchema, Array.isArray(parsed) ? { blocks: parsed } : parsed, "workout spec", "run 'trainheroic skill' for the workout spec format and copy-paste examples.");
3650
+ const publish = values.publish === true;
3651
+ if (publish && values.yes !== true) fail("publishing is athlete-facing; add --yes to build and publish.");
3652
+ const opts = {
3653
+ programId,
3654
+ blocks: spec.blocks,
3655
+ publish
3656
+ };
3657
+ if (values.date !== void 0) opts.date = parseWorkoutDate(values.date);
3658
+ if (values["timeline-day"] !== void 0) opts.timelineDay = toInt(values["timeline-day"], "--timeline-day");
3659
+ if (spec.instruction !== void 0) opts.instruction = spec.instruction;
3660
+ const advice = await collectAdvisories(spec.blocks, library(client));
3661
+ const built = await buildSession(client, opts);
3662
+ const readback = opts.date ? await readSession(client, programId, opts.date, built.pwId) : null;
3663
+ return out({
3664
+ ...built,
3665
+ programId,
3666
+ published: publish,
3667
+ advisories: advice,
3668
+ readback
3669
+ });
3670
+ }
3548
3671
  async function cmdWorkout(client, rest) {
3549
3672
  const [sub, ...a] = rest;
3550
3673
  switch (sub) {
3551
- case "build": {
3552
- const { values, positionals } = parse(a, {
3553
- program: { type: "string" },
3554
- date: { type: "string" },
3555
- "timeline-day": { type: "string" },
3556
- publish: { type: "boolean" },
3557
- yes: { type: "boolean" },
3558
- file: { type: "string" }
3559
- });
3560
- const programId = toInt(need(values.program, "coach workout build --program <id> ..."), "--program");
3561
- if (values.date === void 0 && values["timeline-day"] === void 0) fail("provide --date YYYY-M-D or --timeline-day <n>.");
3562
- const parsed = await jsonInput(positionals[0], values.file);
3563
- const spec = validate(workoutSpecSchema, Array.isArray(parsed) ? { blocks: parsed } : parsed, "workout spec", "run 'trainheroic skill' for the workout spec format and copy-paste examples.");
3564
- const publish = values.publish === true;
3565
- if (publish && values.yes !== true) fail("publishing is athlete-facing; add --yes to build and publish.");
3566
- const opts = {
3567
- programId,
3568
- blocks: spec.blocks,
3569
- publish
3570
- };
3571
- if (values.date !== void 0) opts.date = parseWorkoutDate(values.date);
3572
- if (values["timeline-day"] !== void 0) opts.timelineDay = toInt(values["timeline-day"], "--timeline-day");
3573
- if (spec.instruction !== void 0) opts.instruction = spec.instruction;
3574
- const advice = await collectAdvisories(spec.blocks, library(client));
3575
- const built = await buildSession(client, opts);
3576
- const readback = opts.date ? await readSession(client, programId, opts.date, built.pwId) : null;
3577
- return out({
3578
- ...built,
3579
- published: publish,
3580
- advisories: advice,
3581
- readback
3582
- });
3583
- }
3674
+ case "build": return cmdWorkoutBuild(client, a);
3584
3675
  case "read": {
3585
3676
  const { values } = parse(a, {
3586
3677
  program: { type: "string" },
@@ -4170,14 +4261,20 @@ async function cmdCoachTeamCreate(client, a) {
4170
4261
  return out(await mutate(client, "POST", "/1.0/coach/team/createWithTitleAndCode", { title: need(values.title, "coach team-create --title \"...\"") }));
4171
4262
  }
4172
4263
  async function cmdCoachTeamUpdate(client, a) {
4173
- const usage = "coach team-update --team <id> --title \"...\"";
4264
+ const usage = "coach team-update --team <id> [--title \"...\"] [--group-program <id>] (at least one of --title / --group-program)";
4174
4265
  const { values } = parse(a, {
4175
4266
  team: { type: "string" },
4176
- title: { type: "string" }
4267
+ title: { type: "string" },
4268
+ "group-program": { type: "string" }
4177
4269
  });
4178
4270
  const teamId = toInt(need(values.team, usage), "--team");
4179
- const title = need(values.title, usage);
4180
- return out(await mutate(client, "PUT", `/v5/teams/${teamId}`, { title }));
4271
+ const title = values.title;
4272
+ const groupProgramRaw = values["group-program"];
4273
+ if (title === void 0 && groupProgramRaw === void 0) fail(usage);
4274
+ const args = { teamId };
4275
+ if (title !== void 0) args.title = title;
4276
+ if (groupProgramRaw !== void 0) args.groupProgram = toInt(groupProgramRaw, "--group-program");
4277
+ return out(await updateTeam(client, args));
4181
4278
  }
4182
4279
  async function cmdCoachTeamDelete(client, a) {
4183
4280
  const usage = "coach team-delete --team <id> --yes";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/cli",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,8 +21,8 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "zod": "^4.4.3",
24
- "@trainheroic-unofficial/js": "2.0.2",
25
- "@trainheroic-unofficial/dto": "2.0.2"
24
+ "@trainheroic-unofficial/dto": "2.1.0",
25
+ "@trainheroic-unofficial/js": "2.1.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^26.1.2",
@@ -373,7 +373,7 @@ Deletes a custom exercise. No request body needed. Only works on exercises where
373
373
  | POST | `/v5/sessions/template` | **Create session template** (library) |
374
374
  | DELETE | `/v5/sessions/template/{sessionId}` | **Delete session template** |
375
375
  | POST | `/2.0/coach/calendar/workout/createWorkoutForTimelineDay/{programId}/{day}/null` | **Create session in program** (timeline) |
376
- | POST | `/2.0/coach/calendar/workout/createWorkoutForDay/{calendarId}/{year}/{month}/{day}/0` | **Create session on team calendar date** |
376
+ | POST | `/2.0/coach/calendar/workout/createWorkoutForDay/{calendarId}/{year}/{month}/{day}/0` | **Create session on calendar date** (team or athlete calendar) |
377
377
  | POST | `/2.0/coach/calendar/saveProgramWorkoutSets` | **Add block to session** |
378
378
  | POST | `/2.0/coach/calendar/saveWorkoutSetExercises` | **Add exercise to block** (with prescription) |
379
379
  | POST | `/2.0/coach/calendar/programWorkout/publish` | **Publish session** |
@@ -993,32 +993,33 @@ Returns all available analytics categories and their instances:
993
993
 
994
994
  These are used by the mobile app / athlete-facing client (documented in `train-heroic-schema.yml`):
995
995
 
996
- | Method | Endpoint | Description |
997
- | ------ | ------------------------------------------------------- | ---------------------------------------------- |
998
- | POST | `/auth` | Login |
999
- | GET | `/v5/users/exercises/history` | All exercise history |
1000
- | GET | `/v5/users/exercises/recent` | Recent exercises |
1001
- | GET | `/v5/exercises/{id}/history` | Single exercise history |
1002
- | GET | `/v5/exercises/{id}` | Exercise details |
1003
- | GET | `/v5/exercises/{id}/personalRecords` | Exercise PRs |
1004
- | GET | `/v5/exercises/{id}/stats` | Exercise stats |
1005
- | GET | `/v5/exercises/{id}/stackUp/isSupportedExercise` | Stack-up support check |
1006
- | GET | `/v5/users/circuits/recent` | Recent circuits |
1007
- | GET | `/v5/users/circuits/history` | Circuit history |
1008
- | GET | `/3.0/athlete/programworkout/range?startDate=&endDate=` | Workouts by date range |
1009
- | GET | `/1.0/athlete/programming/programs` | Athlete programs |
1010
- | GET | `/v5/users/{id}` | User profile |
1011
- | GET | `/1.0/athlete/prefs` | Athlete preferences |
1012
- | GET | `/2.0/athlete/workingMax` | Working maxes (all exercises with WM tracking) |
1013
- | GET | `/1.0/athlete/savedworkoutset/{id}` | Saved workout set |
1014
- | GET | `/1.0/athlete/savedworkout/{id}` | Saved workout |
1015
- | GET | `/1.0/user/userInfo` | User info |
1016
- | GET | `/v5/calendars/athletes/{id}/coachAthleteTeam` | Coach-athlete team calendar |
1017
- | GET | `/v5/users/{id}/workingMaxes/{id1}` | Specific working max |
1018
- | GET | `/v5/programs/new` | New programs |
1019
- | GET | `/v5/programs/free` | Free programs |
1020
- | GET | `/v5/athleteProfile/summary` | Athlete profile summary |
1021
- | GET | `/3.0/athlete/leaderboard/{id}` | Leaderboard |
996
+ | Method | Endpoint | Description |
997
+ | ------ | ------------------------------------------------------- | ---------------------------------------------------------- |
998
+ | POST | `/auth` | Login |
999
+ | GET | `/v5/users/exercises/history` | All exercise history |
1000
+ | GET | `/v5/users/exercises/recent` | Recent exercises |
1001
+ | GET | `/v5/exercises/{id}/history` | Single exercise history |
1002
+ | GET | `/v5/exercises/{id}` | Exercise details |
1003
+ | GET | `/v5/exercises/{id}/personalRecords` | Exercise PRs |
1004
+ | GET | `/v5/exercises/{id}/stats` | Exercise stats |
1005
+ | GET | `/v5/exercises/{id}/stackUp/isSupportedExercise` | Stack-up support check |
1006
+ | GET | `/v5/users/circuits/recent` | Recent circuits |
1007
+ | GET | `/v5/users/circuits/history` | Circuit history |
1008
+ | GET | `/3.0/athlete/programworkout/range?startDate=&endDate=` | Workouts by date range |
1009
+ | GET | `/1.0/athlete/programming/programs` | Athlete programs |
1010
+ | GET | `/v5/users/{id}` | User profile |
1011
+ | GET | `/1.0/athlete/prefs` | Athlete preferences |
1012
+ | GET | `/2.0/athlete/workingMax` | Working maxes (all exercises with WM tracking) |
1013
+ | GET | `/1.0/athlete/savedworkoutset/{id}` | Saved workout set |
1014
+ | GET | `/1.0/athlete/savedworkout/{id}` | Saved workout |
1015
+ | GET | `/1.0/user/userInfo` | User info |
1016
+ | GET | `/v5/calendars/athletes/{id}?year=&month=` | **Athlete coach calendar** (program id for CREATE SESSION) |
1017
+ | GET | `/v5/calendars/athletes/{id}/coachAthleteTeam` | Coach-athlete team calendar |
1018
+ | GET | `/v5/users/{id}/workingMaxes/{id1}` | Specific working max |
1019
+ | GET | `/v5/programs/new` | New programs |
1020
+ | GET | `/v5/programs/free` | Free programs |
1021
+ | GET | `/v5/athleteProfile/summary` | Athlete profile summary |
1022
+ | GET | `/3.0/athlete/leaderboard/{id}` | Leaderboard |
1022
1023
 
1023
1024
  ---
1024
1025
 
@@ -1320,16 +1321,22 @@ Saves an existing session as a reusable template in the session library. No requ
1320
1321
 
1321
1322
  #### `PUT /v5/teams/{teamId}`
1322
1323
 
1323
- Updates team properties like title.
1324
+ Updates team properties. `title` is required by the API (HTTP 400 without it). Optional
1325
+ `group_program` re-points the team at an existing parent program/calendar (e.g. another
1326
+ team's `group_program` from `GET /1.0/coach/teams`).
1324
1327
 
1325
1328
  **Request body:**
1326
1329
 
1327
1330
  ```json
1328
1331
  {
1329
- "title": "New Team Name"
1332
+ "title": "New Team Name",
1333
+ "group_program": 4713234
1330
1334
  }
1331
1335
  ```
1332
1336
 
1337
+ `team_create` always auto-creates a calendar; to attach a new team to an existing calendar,
1338
+ create the team then `team_update` / `coach team-update --group-program <id>`.
1339
+
1333
1340
  #### `POST /1.0/coach/team/updatePublishSettings`
1334
1341
 
1335
1342
  Updates the auto-publish settings for a team's program. Takes the full program object with `pub_*` fields controlling auto-publish behavior.