<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLSession/upload(for:from:delegate:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:So12NSURLSessionC10FoundationE6upload3for4from8delegateAC4DataV_So13NSURLResponseCtAC10URLRequestV_AISo0A12TaskDelegate_pSgtYaKF"
  },
  "title" : "upload(for:from:delegate:)"
}
-->

# upload(for:from:delegate:)

Uploads data to a URL based on the specified URL request and delivers the result asynchronously.

```
func upload(for request: URLRequest, from bodyData: Data, delegate: (any URLSessionTaskDelegate)? = nil) async throws -> (Data, URLResponse)
```

## Parameters

`request`

A URL request object that provides request-specific information such as the URL, cache policy, request type, and body data or body stream.

`bodyData`

The body data for the request.

`delegate`

A delegate that receives life cycle and authentication challenge callbacks as the transfer progresses.

## Return Value

An asynchronously-delivered tuple that contains any data returned by the server as a [`Data`](/documentation/Foundation/Data) instance, and a [`URLResponse`](/documentation/Foundation/URLResponse).

---

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)