Skip to Content
FFitDatadraft
Specification

Training

Training routines (step-based and timed timelines), performed workouts, thresholds, targets, ramps, and load bases.

@fitdata/training defines portable training contracts independently of any application or database. It covers strength sessions, timed indoor classes, wearable activities, and personal performance thresholds.

Record kinds

KindLifecycleRequired training fieldsOptional fields
training.routineversionname, namespaced sport, structure (steps or timeline)description, scheduled
training.workoutrevisionNamespaced sport, intervalname, movingSeconds, routine, status, metrics, steps, sessionRpe
training.thresholdrevisionmetric, quantity, effectiveAt, method (tested or estimated)basis, exercise
  • training.workout unifies wearable activity summaries (metrics, movingSeconds) and structured exercise logs (steps). movingSeconds cannot exceed interval.durationSeconds.
  • training.routine unifies reusable class blueprints (no subject, no scheduled) and athlete-assigned sessions (optional subject and scheduled).

Routine structures

A training.routine declares one of two execution layouts in structure:

Step-based (structure.kind: "steps")

Built for strength, mobility, and circuit training where duration follows execution pace:

  • steps: 1–1,000 ordered planned steps.
  • Each step has a local id, exercise ({ id, name? }), 1–20 metric targets, and optional role, load, restSeconds, and side.

Timeline-based (structure.kind: "timeline")

Built for indoor cycling classes, erg workouts, and timed audio sessions running on an elapsed clock:

  • durationSeconds: total class duration.
  • segments: ordered, non-overlapping windows with id, startSeconds, endSeconds, 1–20 targets, and optional label and role.
  • cues (optional): timed cues with atSeconds and at least one of posture, resistance, or text.

Presentation concerns (music playlists, video overlays, player themes) stay outside FitData or under namespaced extensions.

{
  "kind": "training.routine",
  "id": "example:five-minute-climb",
  "version": "1",
  "sport": "fitdata:indoor_cycling",
  "name": "Five-minute climb",
  "structure": {
    "kind": "timeline",
    "durationSeconds": 300,
    "segments": [
      {
        "id": "climb",
        "startSeconds": 0,
        "endSeconds": 300,
        "targets": [
          {
            "metric": "fitdata:power",
            "target": {
              "kind": "ramp",
              "basis": "fitdata:ftp",
              "unit": "%",
              "start": 70,
              "end": 85,
              "interpolation": "linear"
            }
          },
          {
            "metric": "fitdata:cadence",
            "target": {
              "kind": "range",
              "unit": "/min",
              "min": 75,
              "max": 85
            }
          }
        ]
      }
    ],
    "cues": [
      { "atSeconds": 0, "posture": "seated", "text": "Start seated." },
      { "atSeconds": 180, "posture": "standing", "text": "Stand for the final two minutes." }
    ]
  }
}

Performed steps and results

Performed steps inside training.workout carry local id, exercise, tagged result, and optional plannedStepId, role, and side.

  • completed or partial results carry 1–20 metric amounts plus optional load and rpe (0–10).
  • skipped results require a reason.
  • Setting plannedStepId requires a routine reference ({ id, version }) on the workout, and document validation verifies that plannedStepId exists in that routine version's steps or segments.

Targets and loads

Every target pairs a namespaced metric with a tagged target:

Target kindFields and rules
exactQuantity value and unit
rangemin, max, and unit; min <= max
relativeNon-negative fraction plus basis code (e.g. fitdata:ftp), pinned threshold reference, or both
rampstart, end, unit, optional interpolation (linear or step), plus optional basis or pinned threshold (relative ramps require % or 1)

Using a basis code without a pinned threshold lets one routine be shared across athletes and resolved dynamically against each athlete's active training.threshold. When a threshold reference is pinned, its metric must match the target metric.

Loads separate magnitude from mechanical meaning:

basisMeaningAllowed units
external_totalTotal external loadkg, [lb_av]
external_per_handExternal load per handkg, [lb_av]
addedLoad added to bodyweightkg, [lb_av]
assistedPositive assistance magnitudekg, [lb_av]
bodyweight_fractionFraction of bodyweight1

Validation entry points

import { validateTrainingRecord, type Workout } from "@fitdata/training";

const result = validateTrainingRecord(input);
if (result.ok && result.value.kind === "training.workout") {
  const workout: Workout = result.value;
  console.log(workout.sport, result.issues);
}

validateTrainingRecord checks local structure, quantities, loads, ramps, segment windows, cues, local step IDs, and scheduled timezones. Run validateDocument from fitdata to verify cross-record routine and threshold references.

On this page