<!--
{
  "availability" : [
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WatchKit",
  "identifier" : "/documentation/WatchKit/WKURLSessionRefreshBackgroundTask",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "WatchKit"
    ],
    "preciseIdentifier" : "c:objc(cs)WKURLSessionRefreshBackgroundTask"
  },
  "title" : "WKURLSessionRefreshBackgroundTask"
}
-->

# WKURLSessionRefreshBackgroundTask

A task that responds to background URL sessions.

```
class WKURLSessionRefreshBackgroundTask
```

## Overview

Always upload and download data using a <doc://com.apple.documentation/documentation/Foundation/URLSession> background transfer. Background transfers occur in a separate process and continue to transfer data even after your app terminates. Asynchronous uploads and downloads, on the other hand, suspend with your app. Because watchOS apps have a short runtime, you can’t guarantee that an asynchronous transfer finishes before the app suspends. For more information on background transfers, see <doc://com.apple.documentation/documentation/Foundation/downloading-files-in-the-background>.

Schedule a background URL session to download an item as shown below.

```swift
// Create a background session configuration.
let config = URLSessionConfiguration.background(withIdentifier: myRequestID)
config.isDiscretionary = true
config.sessionSendsLaunchEvents = true

// Create the background download task and schedule it to run in 15 minutes.
let urlSession = URLSession(configuration: config,
                            delegate: self,
                            delegateQueue: nil)


let backgroundTask = urlSession.downloadTask(with: url)
backgroundTask.earliestBeginDate = Date().addingTimeInterval(15 * 60)

// Run the task.
backgroundTask.resume()
```

If your app has a complication on the active watch face, it can receive up to four [`WKURLSessionRefreshBackgroundTask`](/documentation/WatchKit/WKURLSessionRefreshBackgroundTask) tasks per hour. To avoid throttling, use the <doc://com.apple.documentation/documentation/Foundation/URLSessionTask/earliestBeginDate> property to schedule background URL session tasks no closer than 15 minutes apart.

Don’t subclass or create instances of this class. Instead, the system instantiates a [`WKURLSessionRefreshBackgroundTask`](/documentation/WatchKit/WKURLSessionRefreshBackgroundTask) object and passes the task object to your extension delegate’s [`handle(_:)`](/documentation/WatchKit/WKApplicationDelegate/handle(_:)-4vdjo) method in response to <doc://com.apple.documentation/documentation/Foundation/URLSession> events. Defer calling the background <doc://com.apple.documentation/documentation/Foundation/URLSession> task’s `setTaskCompleted()` method until all the delegate method calls finish processing.

> Note:
> In watchOS 9 and later, SwiftUI Background tasks are the preferred way to handle background tasks and interactions. For more information, <doc://com.apple.documentation/documentation/SwiftUI/Scene/backgroundTask(_:action:)>.

The system creates a background <doc://com.apple.documentation/documentation/Foundation/URLSession> task when any of the following events occur:

- The server requires authentication to complete a background transfer.
- All background transfers associated with a session identifier complete (either successfully or unsuccessfully).

To get more information about the transfer, create a background configuration object with the same session identifier. Next, create a session object using the configuration object and a session delegate. The system automatically associates the new session with the transfer and calls the appropriate delegate methods.

## Topics

### Accessing background task data

[`sessionIdentifier`](/documentation/WatchKit/WKURLSessionRefreshBackgroundTask/sessionIdentifier)

The identifier for the triggering background transfer.



---

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)