# Workout Events

Events for the workout lifecycle and statistics: workouts, plan workouts, personalized plans, custom workouts, challenges, AI Trainer workouts and the Gym Log.

| Event | Data Fields | Description |
|-------|-------------|-------------|
| workout_opened | id: string, title: string, date: string | A workout's detail page loaded (Workout and Plan integrations, workouts opened from Home). Once per opened workout. Not sent for custom workouts, challenges or AI Trainer workouts |
| workout_started | id: string, date: string | A new run started on the exercise screen, including a restart. In the Gym Log it is sent each time the log screen opens |
| workout_resumed | id: string, date: string | The workout screen opened again during the same run (for example after Android back from the exercise screen). Sent instead of a second `workout_started`, so do not count it as a new attempt. A challenge that has started never resumes: going back into it starts a new run with its own `workout_started` |
| workout_started (legacy home) | workoutId: string | The "Start workout" button of the legacy KinesteX home. The exercise screen then sends its own `workout_started` |
| workout_progress | data: object | Live progress, sent after every completed exercise and on request (see below) |
| workout_ended | id: string, exit_type: string, date: string | Workout session ended (see exit_type values below) |
| workout_overview | data: object | Workout summary, sent when the results screen opens. Sent again when a past session is opened from the AI Trainer's progress. Not sent by the personalized-plan assessment, which ends on its own results |
| workout_restart | data: { workout: string, date: string } | User tapped Restart on the results screen. No `workout_completed` or exit event follows; a new `workout_started` comes when the run starts again. A [custom workout assessment](/docs/data-points/custom-assessment-events) sends it too |
| workout_completed | data: { workout: string, date: string } | The user left the results screen (Continue or close). `workout` is the workout title. Always followed by exactly one routing event, see [Navigation Events](/docs/data-points/navigation-events) |
| statistic_sheet_opened | - | The motion replay sheet opened on the results screen |
| statistic_subpage_opened | - | The detailed per-exercise breakdown opened on the results screen |
| statistic_subpage_closed | - | The detailed breakdown closed |

On the results screen the events come in this order: `workout_overview`, `challenge_completed` (challenges and runs started from Home), `exercise_overview`, `custom_assessment_completed` (custom workout assessments), then the [session save events](/docs/data-points/session-upload-events) when saving is on.

**Custom Workout loading:**

| Event | Data Fields | Description |
|-------|-------------|-------------|
| custom_workout_ready | message: string ("Ready to receive workout data") | The Custom Workout page is up and waiting for your workout data |
| commit_screen_shown | data: { commit_button: boolean } | Verification finished and the loading screen shows its own progress, so you can drop your loading cover. `commit_button` is `true` with `showCommitScreen`. Sent again if it changes |
| all_resources_loaded | message: string ("Custom workout data loaded successfully") | Videos, rest speech, motion models and pose tracking are loaded. Custom Workout and AI Trainer workouts. Not sent while a failed load waits for Retry. On a Custom Workout, send `{ workout_activity_action: "start" }` now (with `showCommitScreen`, after `workout_committed`) |
| workout_committed | data: { orientation_permission: string } | Custom Workout with `showCommitScreen` only: the user tapped "I'm committed". `orientation_permission` is `"granted"`, `"denied"`, `"unsupported"` or `"error"`. Send `start` after it |

**Command echoes.** When you send a `workout_activity_action`, the workout confirms it with an event of the same `type`, carrying `date` ("DD MM YYYY HH:MM:SS"):

| Event | When |
|-------|------|
| pause_workout / resume_workout | Only when the state changed: pausing a paused workout sends nothing. A pause the user taps on screen sends nothing either |
| mute_workout / unmute_workout | Every time. The [Camera component](/docs/data-points/camera-events) echoes these too |
| mute_speech / unmute_speech | Every time. Workouts and Gym Log only: the Camera component ignores them |

`log` replies with `workout_progress` (below).

**Gym Log (motion tracking off):** in workouts, plans, custom workouts and the AI Trainer, users log their sets in the Gym Log when AI motion tracking is off (unless you pass `selfModeEnabled: false`). It sends the same `workout_started`, `exercise_completed`, `workout_progress` and `workout_ended` events with the same shapes, echoes the commands above, and ends on the same results events. The differences: `workout_started` is sent each time the log screen opens; `exercise_completed` is sent for every set closed (logged or skipped), again after a redo, and again with the corrected numbers when the user edits a set, so treat it as an update; its `mistakes` is always `[]`; `workout_progress` follows each batch of corrections; `workout_ended` is only `complete` or `exit`. There are no camera or motion events. See [Motion Tracking Settings](/docs/customization-parameters/motion-tracking-settings).

**workout_progress Data Structure:**
```
{
  completion_percentage: number,  // 0-100, same formula as workout_overview
  completed_reps_count: number,
  target_reps_count: number,
  calories_burned: number,        // 2 decimal places
  exercise_index: number,         // 1-based, rest periods not counted
  total_exercises: number,        // rest periods not counted
  workout_id?: string,            // omitted when unknown
  workout_title?: string,         // omitted when unknown
  date: string                    // "DD MM YYYY HH:MM:SS", device-local
}
```

To get fresh numbers at any moment (for example, right before your app goes to the background), send `{ workout_activity_action: "log" }`. The SDK replies with a new `workout_progress`, or with `error_occurred` (`severity: "warning"`, `message: "log: no active workout"`) when no workout is loaded. A workout counts as loaded from its detail page until the user leaves the results screen.

**workout_ended exit_type values:**

| Value | Meaning |
|-------|---------|
| complete | User finished the entire workout including outro (in the Gym Log: every set was logged or skipped) |
| exit | User abandoned the workout mid-session |
| outro | User exited from the outro/cooldown screen after completing all exercises. Not sent by the Gym Log |

**workout_overview Data Structure:**
```
{
  workout_title: string,            // Workout name (omitted when unknown)
  workout_id: string,               // Unique workout ID (omitted when unknown)
  target_duration_seconds: number,  // Target workout duration (seconds)
  workout_duration_seconds: number, // Total wall-clock session time
                                    // (includes rest, transitions, pauses).
                                    // For challenges/assessments this equals
                                    // total_time_spent (no wall-clock concept)
  total_time_spent: number,         // Active exercise time only (seconds)
  completed_reps_count: number,     // Total completed reps
  target_reps_count: number,        // Total target reps
  calories_burned: number,          // Calories (2 decimal places)
  completion_percentage: number,    // Completion % (2 decimals)
  total_mistakes: number,           // Total mistake count
  accuracy_score: number,           // Overall accuracy (0-100)
  efficiency_score: number,         // Efficiency metric (0-100)
  total_exercise: number,           // Number of exercises (rest periods not counted)
  actual_hold_time_seconds: number, // Time in correct position
  target_hold_time_seconds: number  // Target hold time
}
```

**Note:** Use `workout_duration_seconds` to display or log the full session time (including rest periods). Use `total_time_spent` if you only need active exercise time.

The same `data` also carries older names of these values: `workout` (the workout id or `null`), `total_repeats`, `total_calories`, `percentage_completed`, `total_max_reps`, `total_accuracy_score` and `total_max_time`. Prefer the names above. The Camera component sends a `workout_overview` with different fields, see [Camera & Frame Events](/docs/data-points/camera-events).

**Handling Workout Overview**

_Swift (iOS)_
```swift
case .workout_overview(let json):
    // The summary is under "data"; json is the whole event
    if let overview = json["data"] as? [String: Any],
       let calories = overview["calories_burned"] as? Double,
       let completion = overview["completion_percentage"] as? Double {
        print("Burned \(calories) cal, \(completion)% complete")
    }
```

_Kotlin (Android)_
```kotlin
is WebViewMessage.WorkoutOverview -> {
    // message.data is the whole event; the summary is under "data"
    val overview = message.data["data"] as? Map<*, *>
    val calories = overview?.get("calories_burned")
    val completion = overview?.get("completion_percentage")
    Log.d("Workout", "Burned $calories cal, $completion% complete")
}
```

_React Native_
```jsx
case "workout_overview": {
  // data is the whole event; the summary is under data.data
  const { calories_burned, completion_percentage, accuracy_score } = data.data;
  console.log(`Workout: ${completion_percentage}% complete`);
  console.log(`Calories: ${calories_burned}, Accuracy: ${accuracy_score}`);
  break;
}
```

_Flutter_
```dart
if (message is WorkoutOverview) {
  // message.data is the whole event; the summary is under 'data'
  final overview = message.data['data'];
  print("Calories: ${overview?['calories_burned']}");
  print("Completion: ${overview?['completion_percentage']}%");
  print("Accuracy: ${overview?['accuracy_score']}");
}
```

_HTML / JavaScript_
```html
case "workout_overview":
  const stats = message.data;
  console.log("Workout:", stats.workout_title);
  console.log("Calories:", stats.calories_burned);
  console.log("Accuracy:", stats.accuracy_score);
  break;
```

_React (TypeScript)_
```tsx
case "workout_overview": {
  // data is the whole event; the summary is under data.data
  const { calories_burned, completion_percentage, accuracy_score } = data.data;
  console.log(`Workout: ${completion_percentage}% complete`);
  console.log(`Calories: ${calories_burned}, Accuracy: ${accuracy_score}`);
  break;
}
```

---
Source: https://www.kinestex.com/docs/data-points/workout-events · Index: https://www.kinestex.com/llms.txt
