---
metadata:
  - name: generator
    content: Diplodoc Platform v5.44.0
alternate:
  - https://yandex.com/dev/disk-api/doc/en/reference/upload.md
  - https://yandex.com/dev/disk-api/doc/ru/reference/upload.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/disk-api/doc/en/llms.txt

# Uploading a file to Yandex Disk

To upload a file to Yandex Disk:

1. [Request an upload URL.](#url-request)
1. [Upload the file](#response-upload) to the address.


## Upload URL request {#url-request}
When you provide the Yandex Disk API with the upload path, you receive a URL to access the file uploader.
### Request format {#request}

Use the GET method to send a request for an upload URL.
```
https://cloud-api.yandex.net/v1/disk/resources/upload
 ? [path](*popup-path)=<path for the file upload>
 & [[overwrite](*popup-overwrite)=<overwrite flag>]
 & [[fields](*popup-fields)=<properties to include in the response>]
```

path[*](*popup-a)
: The path the file should be uploaded to. For example, `%2Fbar%2Fphoto.png`. The maximum file name length is 255 characters. The maximum path length is 32760 characters. <br>
  
  <!-- source: en/_includes/reference/parameters-warehouse/id-format/path-encoding.md -->
  The path in the parameter value should be encoded in URL format.
  <!-- endsource: en/_includes/reference/parameters-warehouse/id-format/path-encoding.md -->


overwrite
: File overwrite flag. Used if the file is uploaded to a folder that already contains a file with the same name. <br>
Supported values:
- `false`: don't overwrite the file and cancel upload (default value).
- `true`: delete the existing file with the same name and save the uploaded file.


fields
: List of JSON properties to include in the response. Keys not specified in this list are omitted when generating a response. If the parameter isn't specified, the response is returned in full without omitting anything. <br>
Key names should be separated by commas, and embedded keys should be separated by dots. For example: `name,_embedded.items.path`.


\* Required parameter.

### Response format {#response}

If the request is processed without errors, the API returns the `200 OK` code. The [Link](https://yandex.com/dev/disk-api/doc/en/reference/response-objects.md#link) object in the response body contains the URL generated to upload the file. If this URL isn't requested within 30 minutes, it stops working and you have to request a new URL.

<!-- source: en/_includes/reference/response-error.md -->
If the request caused an error, the relevant response code is returned, and the response body contains an [error description](https://yandex.com/dev/disk-api/doc/en/reference/response-objects.md#error).
<!-- endsource: en/_includes/reference/response-error.md -->

Sample response:

```json
{
  "href": "https://uploader1d.dst.yandex.net:443/upload-target/...",
  "method": "PUT",
  "templated": false
}
```

<!-- source: en/_includes/reference/response-objects/id-link/link-table.md -->


#|
|| **Element** | **Description**||
|| `href` | URL. It may be a URL template. See the `templated` key. ||
|| `method` | The HTTP method for requesting the URL from the `href` key. ||
|| `templated` | Indicates a URL template according to [RFC 6570](http://tools.ietf.org/html/rfc6570). Possible values:

- "true" — URL template. To send a request to this address, replace the placeholder values in the curly brackets with the parameter values.
- "false" — The URL can be requested without changes.||
   |#
<!-- endsource: en/_includes/reference/response-objects/id-link/link-table.md -->



## Uploading a file to a URL {#response-upload}

Send the file to the [upload URL](#response) using the PUT method within 30 minutes of getting the URL (after 30 minutes, the link will expire and you'll have to request a new link). You don't need an OAuth token to upload files to the storage.

Sample upload URL:

```no-highlight
https://uploader1d.dst.yandex.net:443/upload-target/20240424T101447.217.utd.52csloukwvq67nab1yc84a3xw-k1d.6625
```

### Response format {#response-upload}

If the request is processed without errors, the API returns the `201 Created` code.

Sample HTTP response:

```
HTTP/1.1 201 Created
Content-Length: 0

```

### Response codes when uploading a file {#section_wkj_t3r_gz}

In the file is uploaded without errors, the API returns the `201 Created` code.

Other HTTP response codes:

- `202 Accepted` — The file has been received by the server but hasn't been moved to Yandex Disk yet.

- `412 Precondition Failed` — Wrong range was passed in the `Content-Range` header when uploading the file.

- `413 Payload Too Large` — The file size is larger than allowed. If you have a [Yandex 360 subscription](https://yandex.com/support/yandex-360/index.html), you can upload files up to 50 GB in size. Otherwise, the file size is limited to 1 GB.

- `500 Internal Server Error` or `503 Service Unavailable` — Server error. Try re-uploading the file.

- `507 Insufficient Storage` — There isn't enough available space on the user's Disk to upload the file.

[*popup-path]: The path the file should be uploaded to. For example, `%2Fbar%2Fphoto.png`. The maximum file name length is 255 characters. The maximum path length is 32760 characters. <br>
  
  
The path in the parameter value should be encoded in URL format.

[*popup-overwrite]: File overwrite flag. Used if the file is uploaded to a folder that already contains a file with the same name. <br>
Supported values:
- `false`: don't overwrite the file and cancel upload (default value).
- `true`: delete the existing file with the same name and save the uploaded file.

[*popup-fields]: List of JSON properties to include in the response. Keys not specified in this list are omitted when generating a response. If the parameter isn't specified, the response is returned in full without omitting anything. <br>
Key names should be separated by commas, and embedded keys should be separated by dots. For example: `name,_embedded.items.path`.

[*popup-a]: Required parameter.