<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKHeartbeatSeriesBuilder/finishSeries(completion:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKHeartbeatSeriesBuilder(im)finishSeriesWithCompletion:"
  },
  "title" : "finishSeries(completion:)"
}
-->

# finishSeries(completion:)

Finalizes the series and returns the resulting heartbeat series sample.

```
func finishSeries(completion: @escaping @Sendable (HKHeartbeatSeriesSample?, (any Error)?) -> Void)
```

## Parameters

`completion`

The completion handler called by the builder after it attempts to create and save the heartbeat series sample. The completion handler takes the following parameters:

- `heartbeatSeries`: If successful it contains the resuting sample; otherwise, `nil`.
- `error`: If an error occurs, this contains an object that describes the error; otherwise, `nil`.

## Discussion

Call [`finishSeries(completion:)`](/documentation/HealthKit/HKHeartbeatSeriesBuilder/finishSeries(completion:)) after inserting all the heartbeats for the series. The series builder creates the series sample, saves it to the HealthKit store, and passes it to the completion handler.

Calling this method before inserting any heartbeats results in an error. Also, calling this method invalidates the series builder; you cannot call any other series builder methods after calling this method.

---

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)