<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLSession/init(configuration:delegate:delegateQueue:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLSession(cm)sessionWithConfiguration:delegate:delegateQueue:"
  },
  "title" : "init(configuration:delegate:delegateQueue:)"
}
-->

# init(configuration:delegate:delegateQueue:)

Creates a session with the specified session configuration, delegate, and operation queue.

```
init(configuration: URLSessionConfiguration, delegate: (any URLSessionDelegate)?, delegateQueue queue: OperationQueue?)
```

## Parameters

`configuration`

A configuration object that specifies certain behaviors, such as caching policies, timeouts, proxies, pipelining, TLS versions to support, cookie policies, and credential storage.

    See [`URLSessionConfiguration`](/documentation/Foundation/URLSessionConfiguration)     for more information.

`delegate`

A session delegate object that handles requests for authentication and other session-related events.

    This delegate object is responsible for handling authentication challenges, for making caching decisions, and for handling other session-related events. If     `nil`    , the class should be used only with methods that take completion handlers.
  
  > Important:
  > The session object keeps a strong reference to the delegate until your app exits or explicitly invalidates the session. If you do not invalidate the session by calling the ``doc://com.apple.foundation/documentation/Foundation/URLSession/invalidateAndCancel()`` or ``doc://com.apple.foundation/documentation/Foundation/URLSession/finishTasksAndInvalidate()`` method, your app leaks memory until it exits.

`queue`

An operation queue for scheduling the delegate calls and completion handlers. The queue should be a serial queue, in order to ensure the correct ordering of callbacks. If `nil`, the session creates a serial operation queue for performing all delegate method calls and completion handler calls.

## Discussion

---

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)