---
title: "finishSeries(completion:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkheartbeatseriesbuilder/finishseries(completion:)"
---

# finishSeries(completion:)

Finalizes the series and returns the resulting heartbeat series sample.

## Declaration

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

```swift
func finishSeries() async throws -> HKHeartbeatSeriesSample
```

## 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:

## Discussion

Discussion Call 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.
