<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLSessionTaskDelegate/urlSession(_:task:willBeginDelayedRequest:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSURLSessionTaskDelegate(im)URLSession:task:willBeginDelayedRequest:completionHandler:"
  },
  "title" : "urlSession(_:task:willBeginDelayedRequest:completionHandler:)"
}
-->

# urlSession(_:task:willBeginDelayedRequest:completionHandler:)

Tells the delegate that a delayed URL session task will now begin loading.

```
optional func urlSession(_ session: URLSession, task: URLSessionTask, willBeginDelayedRequest request: URLRequest, completionHandler: @escaping @Sendable (URLSession.DelayedRequestDisposition, URLRequest?) -> Void)
```

## Parameters

`session`

The session containing the delayed request.

`task`

The task handling the delayed request.

`request`

The request that was delayed.

`completionHandler`

A completion handler to perform the request. The completion handler takes two parameters: a disposition that tells the task how to proceed, and a new request object that is only used if the disposition is [`URLSession.DelayedRequestDisposition.useNewRequest`](/documentation/Foundation/URLSession/DelayedRequestDisposition/useNewRequest).

## Discussion

This method is called when a background session task with a delayed start time (as set with the [`earliestBeginDate`](/documentation/Foundation/URLSessionTask/earliestBeginDate) property) is ready to start. This delegate method should only be implemented if the request might become stale while waiting for the network load and needs to be replaced by a new request.

For loading to continue, the delegate must call the completion handler, passing in a disposition that indicates how the task should proceed. Passing the [`URLSession.DelayedRequestDisposition.cancel`](/documentation/Foundation/URLSession/DelayedRequestDisposition/cancel) disposition is equivalent to calling [`cancel()`](/documentation/Foundation/URLSessionTask/cancel()) on the task directly.

---

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)