<!--
{
  "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/HKQuantityTypeIdentifier/heartRate",
  "metadataVersion" : "0.1.0",
  "role" : "Type Property",
  "symbol" : {
    "kind" : "Type Property",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:@HKQuantityTypeIdentifierHeartRate"
  },
  "title" : "heartRate"
}
-->

# heartRate

A quantity sample type that measures the user’s heart rate.

```
static let heartRate: HKQuantityTypeIdentifier
```

## Discussion

These samples use count/time units (described in [`HKUnit`](/documentation/HealthKit/HKUnit)) and measure discrete values (described in [`HKQuantityAggregationStyle`](/documentation/HealthKit/HKQuantityAggregationStyle)). Sample data may be condensed and/or coalesced by HealthKit. For more information, see <doc://com.apple.healthkit/documentation/HealthKit/accessing-condensed-workout-samples>.

Heart rate samples may include motion context information, which is stored as metadata using the [`HKMetadataKeyHeartRateMotionContext`](/documentation/HealthKit/HKMetadataKeyHeartRateMotionContext) key. The value of this key is an <doc://com.apple.documentation/documentation/Foundation/NSNumber> object that contains a [`HKHeartRateMotionContext`](/documentation/HealthKit/HKHeartRateMotionContext) value.

The motion context gives additional information about the user’s activity level when the heart rate sample was taken. Apple Watch uses the following guidelines when setting the motion context:

1. If the user has been still for at least 5 minutes prior to the sample, the context is set to the [`HKHeartRateMotionContext.sedentary`](/documentation/HealthKit/HKHeartRateMotionContext/sedentary) value.
2. If the user is in motion, the context is set to the [`HKHeartRateMotionContext.active`](/documentation/HealthKit/HKHeartRateMotionContext/active) value.

You can add motion context to the metadata of any heart rate samples that you create. This means other apps may also save heart rate samples with (or without) the [`HKMetadataKeyHeartRateMotionContext`](/documentation/HealthKit/HKMetadataKeyHeartRateMotionContext) metadata key.

Note that not all heart rate samples have a motion context. For example, if Apple Watch cannot determine the motion context, it creates samples without a [`HKMetadataKeyHeartRateMotionContext`](/documentation/HealthKit/HKMetadataKeyHeartRateMotionContext) metadata key. In addition, heart rate samples recorded by an Apple Watch (1st generation) or by a device running watchOS 3 or earlier do not have the motion context metadata key. Treat these samples as if they used the [`HKHeartRateMotionContext.notSet`](/documentation/HealthKit/HKHeartRateMotionContext/notSet) motion context.

## Topics

### Metadata Keys

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

The location where a specific heart rate reading was taken.

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

The user’s activity level when the heart rate sample was measured.

## See Also

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

The identifiers that create quantity type objects.

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

A sample that represents a quantity, including the value and the units.

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

An object that stores a value for a given unit.



---

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)