<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKMetadataKeySyncIdentifier",
  "metadataVersion" : "0.1.0",
  "role" : "Global Variable",
  "symbol" : {
    "kind" : "Global Variable",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:@HKMetadataKeySyncIdentifier"
  },
  "title" : "HKMetadataKeySyncIdentifier"
}
-->

# HKMetadataKeySyncIdentifier

A unique string that identifies a piece of data so it can be updated and synced.

```
let HKMetadataKeySyncIdentifier: String
```

## Discussion

This key takes a string value. If you add this key to an object’s metadata, you must also add the [`HKMetadataKeySyncVersion`](/documentation/HealthKit/HKMetadataKeySyncVersion) key.

When you save an [`HKObject`](/documentation/HealthKit/HKObject) with a sync identifier, the system looks for any existing objects with the same sync identifier. If it finds a match, the system compares the objects’ [`HKMetadataKeySyncVersion`](/documentation/HealthKit/HKMetadataKeySyncVersion) values. If the new object has a greater sync version, the system replaces the old object with the new one. If the old object is associated with a workout or part of a correlation, the system also replaces the old object in the workout or correlation.

---

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)