---
title: "addHeartbeatWithTimeInterval(sinceSeriesStartDate:precededByGap:completion:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkheartbeatseriesbuilder/addheartbeatwithtimeinterval(sinceseriesstartdate:precededbygap:completion:)"
---

# addHeartbeatWithTimeInterval(sinceSeriesStartDate:precededByGap:completion:)

Adds a heartbeat to the series.

## Declaration

```swift
func addHeartbeatWithTimeInterval(sinceSeriesStartDate timeIntervalSinceStart: TimeInterval, precededByGap: Bool, completion: @escaping @Sendable (Bool, (any Error)?) -> Void)
```

```swift
func addHeartbeat(at timeIntervalSinceStart: TimeInterval, precededByGap: Bool) async throws
```

## Parameters

- `timeIntervalSinceStart`: The time of the heartbeat, measured from the series builder’s start date. This must be a positive value.
- `precededByGap`: A Boolean value that indicates whether this heartbeat was immediately preceded by a gap in the data, indicating that one or more heartbeats may be missing.
- `completion`: The completion handler called by the builder after it attempts to add the heartbeat to the series. The completion handler takes the following parameters:

## See Also

### Adding Data

- [addMetadata(_:completion:)](healthkit/hkheartbeatseriesbuilder/addmetadata(_:completion:).md)
