---
title: "init(workoutConfiguration:start:end:metadata:)"
framework: healthkit
role: symbol
role_heading: Initializer
path: "healthkit/hkworkoutactivity/init(workoutconfiguration:start:end:metadata:)"
---

# init(workoutConfiguration:start:end:metadata:)

Creates a workout activity using the provided configuration, start date, end date, and metadata.

## Declaration

```swift
init(workoutConfiguration: HKWorkoutConfiguration, start startDate: Date, end endDate: Date?, metadata: [String : Any]?)
```

## Parameters

- `workoutConfiguration`: The configuration information for this part of the workout. For doc://com.apple.healthkit/documentation/HealthKit/HKWorkoutActivityType/swimBikeRun workouts, the activity’s configuration must use the doc://com.apple.healthkit/documentation/HealthKit/HKWorkoutActivityType/swimming, doc://com.apple.healthkit/documentation/HealthKit/HKWorkoutActivityType/cycling, or doc://com.apple.healthkit/documentation/HealthKit/HKWorkoutActivityType/running activity types. For interval training, the activity’s configuration must use the same activity type as the containing workout.
- `startDate`: The activity’s start date and time.
- `endDate`: The activity’s end date and time. Set this value to nil if the activity is still in progress. When set to a non-nil value, the end date must be equal to or later than its start date. A workout can’t have overlapping activities.
- `metadata`: Metadata that provides additional information about the activity.

## Discussion

Discussion
