<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKWorkoutSession/beginNewActivity(configuration:date:metadata:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKWorkoutSession(im)beginNewActivityWithConfiguration:date:metadata:"
  },
  "title" : "beginNewActivity(configuration:date:metadata:)"
}
-->

# beginNewActivity(configuration:date:metadata:)

Begins a new workout activity in the workout session.

```
func beginNewActivity(configuration workoutConfiguration: HKWorkoutConfiguration, date: Date, metadata: [String : Any]?)
```

## Parameters

`workoutConfiguration`

The configuration information for the activity. For [`HKWorkoutActivityType.swimBikeRun`](/documentation/HealthKit/HKWorkoutActivityType/swimBikeRun) workouts, the activity’s configuration must use the [`HKWorkoutActivityType.swimming`](/documentation/HealthKit/HKWorkoutActivityType/swimming), [`HKWorkoutActivityType.cycling`](/documentation/HealthKit/HKWorkoutActivityType/cycling), or [`HKWorkoutActivityType.running`](/documentation/HealthKit/HKWorkoutActivityType/running) activity types. For interval training, the activity’s configuration must use the same activity type as the containing workout.

`date`

The activity’s start date and time.

`metadata`

Metadata that provides additional information about the activity.

## Discussion

This method asynchronously creates a new workout activity. HealthKit calls the session delegate’s [`workoutSession(_:didBeginActivityWith:date:)`](/documentation/HealthKit/HKWorkoutSessionDelegate/workoutSession(_:didBeginActivityWith:date:)) method after the activity begins. If the workout already has a current activity, HealthKit also ends that activity.

HealthKit may also set the data source’s [`typesToCollect`](/documentation/HealthKit/HKLiveWorkoutDataSource/typesToCollect) value based on the new activity. If you’ve never modified the types that the data source collects (for example, by calling [`enableCollection(for:predicate:)`](/documentation/HealthKit/HKLiveWorkoutDataSource/enableCollection(for:predicate:)) or [`disableCollection(for:)`](/documentation/HealthKit/HKLiveWorkoutDataSource/disableCollection(for:))), HealthKit automatically sets the [`typesToCollect`](/documentation/HealthKit/HKLiveWorkoutDataSource/typesToCollect) property to a set of relevant data types based on the new actiity. However, if you’ve explicitly set the collected data types, HealthKit won’t modify them; therefore, you may need to update them for the new activity.

---

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)