<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKWorkout",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKWorkout"
  },
  "title" : "HKWorkout"
}
-->

# HKWorkout

A workout sample that stores information about a single physical activity.

```
class HKWorkout
```

## Overview

The [`HKWorkout`](/documentation/HealthKit/HKWorkout) class is a concrete subclass of the [`HKSample`](/documentation/HealthKit/HKSample) class; however, they behave somewhat differently than other sample types.

- You don’t need a specific type identifier to create the [`HKWorkoutType`](/documentation/HealthKit/HKWorkoutType) instance. All workouts use the same type identifier.
- You must provide an [`HKWorkoutActivityType`](/documentation/HealthKit/HKWorkoutActivityType) value for each workout. This value defines the type of activity performed during the workout.
- After saving the workout to the HealthKit store, you must associate additional samples with the workout (for example, active energy burned or distance samples). These samples provide fine-grained details. Use the [`add(_:to:completion:)`](/documentation/HealthKit/HKHealthStore/add(_:to:completion:)) method to associate them with the workout.

![An illustration showing how a workout is created and added to the store.](images/com.apple.healthkit/media-3570087@2x.png)

The workout records a summary of information about a single physical activity (for example, the duration, total distance, and total energy burned). It also acts as a container for other [`HKSample`](/documentation/HealthKit/HKSample) objects. You can associate any number of samples with a workout, adding details over the course of the workout. For example, you may want to break a single run into a number of shorter intervals, and then add samples to track the user’s heart rate, energy burned, distance traveled, and steps taken for each interval. For more information, see <doc://com.apple.healthkit/documentation/HealthKit/adding-samples-to-a-workout>.

> Note:
> If a workout has summary information, it also needs a set of associated samples that add up to the summary’s total. See <doc://com.apple.healthkit/documentation/HealthKit/adding-samples-to-a-workout>.

HealthKit supports a wide range of activity types. For a complete list, see [`HKWorkoutActivityType`](/documentation/HealthKit/HKWorkoutActivityType).

Workouts are mostly immutable. You set their properties when you instantiate the workout, and they can’t change. However, you can continue to add samples to the workouts.

### Fill the Activity rings

Workouts can contribute to the Move and Exercise rings in the Activity app. To affect the rings, you must associate one or more active energy burned samples with the workout. Additionally:

- In watchOS. Use a workout session to track the user’s activity. When the session has ended, create a workout object and the associated active energy burned samples. For more information, see [`HKWorkoutSession`](/documentation/HealthKit/HKWorkoutSession).

The system updates the Move ring based on the active energy burned samples. It updates the Exercise ring based on the amount of time the user spent actually exerting themselves during the workout session, as calculated by the watch’s sensors.

- In iOS. No additional work is necessary. Workout objects automatically contribute to both the Move and Exercise rings. The Exercise ring increases by the workout’s total duration, and the Move ring increases by the number of calories in the associated active energy burned samples. HealthKit also increases the Stand ring by one hour for each wall-clock hour that the workout overlaps.

Create and save workouts on the device that makes the most sense for your application—typically the device processing the user’s workout.

### Extend workouts

As with many HealthKit classes, don’t subclass the [`HKWorkout`](/documentation/HealthKit/HKWorkout) class. You may extend workouts by adding metadata with custom keys as appropriate for your app.

For more information, see the methods [`init(activityType:start:end:duration:totalEnergyBurned:totalDistance:metadata:)`](/documentation/HealthKit/HKWorkout/init(activityType:start:end:duration:totalEnergyBurned:totalDistance:metadata:)) and [`init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:metadata:)`](/documentation/HealthKit/HKWorkout/init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:metadata:)).

## Topics

### Creating workouts

[`init(activityType:start:end:)`](/documentation/HealthKit/HKWorkout/init(activityType:start:end:))

Instantiates a new workout.

[`init(activityType:start:end:duration:totalEnergyBurned:totalDistance:metadata:)`](/documentation/HealthKit/HKWorkout/init(activityType:start:end:duration:totalEnergyBurned:totalDistance:metadata:))

Instantiates a new workout that includes the energy burned, distance, and metadata for the workout.

[`init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:metadata:)`](/documentation/HealthKit/HKWorkout/init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:metadata:))

Instantiates a new workout whose duration is calculated based on the start and end dates and the provided workout events.

[`init(activityType:start:end:duration:totalEnergyBurned:totalDistance:device:metadata:)`](/documentation/HealthKit/HKWorkout/init(activityType:start:end:duration:totalEnergyBurned:totalDistance:device:metadata:))

Instantiates a new workout activity that includes the device that produced the sample data.

[`init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:device:metadata:)`](/documentation/HealthKit/HKWorkout/init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:device:metadata:))

Instantiates a workout that includes both workout events and the device that produced the sample data.

[`init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:totalFlightsClimbed:device:metadata:)`](/documentation/HealthKit/HKWorkout/init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:totalFlightsClimbed:device:metadata:))

Instantiates a workout using a variety of data, including the number of flights of stairs climbed.

[`init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:totalSwimmingStrokeCount:device:metadata:)`](/documentation/HealthKit/HKWorkout/init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:totalSwimmingStrokeCount:device:metadata:))

Instantiates a workout using a variety of data, including the number of strokes while swimming.

### Accessing workout data

[`duration`](/documentation/HealthKit/HKWorkout/duration)

The workout’s duration.

[`workoutActivityType`](/documentation/HealthKit/HKWorkout/workoutActivityType)

The type of activity performed during the workout.

[`workoutActivities`](/documentation/HealthKit/HKWorkout/workoutActivities)

[`workoutEvents`](/documentation/HealthKit/HKWorkout/workoutEvents)

An array of workout event objects.

[`statistics(for:)`](/documentation/HealthKit/HKWorkout/statistics(for:))

Returns the workout’s statistics for the provided quantity type.

[`allStatistics`](/documentation/HealthKit/HKWorkout/allStatistics)

A dictionary that contains all the statistics for the workout.

[`totalDistance`](/documentation/HealthKit/HKWorkout/totalDistance)

The total distance traveled during the workout.

[`totalEnergyBurned`](/documentation/HealthKit/HKWorkout/totalEnergyBurned)

The total active energy burned during the workout.

[`totalFlightsClimbed`](/documentation/HealthKit/HKWorkout/totalFlightsClimbed)

The total number of flights of stairs climbed during the workout.

[`totalSwimmingStrokeCount`](/documentation/HealthKit/HKWorkout/totalSwimmingStrokeCount)

The total stroke count for the workout.

### Accessing zone data

[`zoneGroupsByType`](/documentation/HealthKit/HKWorkout/zoneGroupsByType)

A property that contains a dictionary that maps quantity types to their zone groups for this workout.

[`zoneGroup(for:)`](/documentation/HealthKit/HKWorkout/zoneGroup(for:))

Returns the current zone group for the specified quantity type.

### Specifying sort identifiers

[`HKWorkoutSortIdentifierDuration`](/documentation/HealthKit/HKWorkoutSortIdentifierDuration)

A constant for sorting workouts based on their duration.

[`HKWorkoutSortIdentifierTotalDistance`](/documentation/HealthKit/HKWorkoutSortIdentifierTotalDistance)

A constant for sorting workouts based on their total distance.

[`HKWorkoutSortIdentifierTotalEnergyBurned`](/documentation/HealthKit/HKWorkoutSortIdentifierTotalEnergyBurned)

A constant for sorting workouts based on the total energy burned.

### Specifying predicate key paths

[`HKPredicateKeyPathWorkoutType`](/documentation/HealthKit/HKPredicateKeyPathWorkoutType)

The key path for accessing the workout’s type.

[`HKPredicateKeyPathWorkoutDuration`](/documentation/HealthKit/HKPredicateKeyPathWorkoutDuration)

The key path for accessing the workout’s duration.

[`HKPredicateKeyPathWorkoutTotalDistance`](/documentation/HealthKit/HKPredicateKeyPathWorkoutTotalDistance)

The key path for accessing the workout’s total distance.

[`HKPredicateKeyPathWorkoutTotalEnergyBurned`](/documentation/HealthKit/HKPredicateKeyPathWorkoutTotalEnergyBurned)

The key path for accessing the workout’s total energy burned.

[`HKPredicateKeyPathWorkoutAverageQuantity`](/documentation/HealthKit/HKPredicateKeyPathWorkoutAverageQuantity)

The key path for accessing workouts with a matching average quantity.

[`HKPredicateKeyPathWorkoutMaximumQuantity`](/documentation/HealthKit/HKPredicateKeyPathWorkoutMaximumQuantity)

The key path for accessing workouts with a matching maximum quantity.

[`HKPredicateKeyPathWorkoutMinimumQuantity`](/documentation/HealthKit/HKPredicateKeyPathWorkoutMinimumQuantity)

The key path for accessing workouts with a matching minimum quantity.

[`HKPredicateKeyPathWorkoutSumQuantity`](/documentation/HealthKit/HKPredicateKeyPathWorkoutSumQuantity)

The key path for accessing workouts with a matching sum.

### Specifying metadata keys

  <doc://com.apple.healthkit/documentation/HealthKit/workout-metadata-keys>

### Setting additional properties

[`workoutPlan`](/documentation/HealthKit/HKWorkout/workoutPlan)



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)