Deleting a file or folder

To delete files and folders on a user's Disk, specify the path to the resource to delete. Keep in mind that moving resources to the Trash does not change the space available on Yandex.Disk. To free up space, you should also delete resources from the Trash.

Request format

Use the DELETE method to send the delete request.

https://cloud-api.yandex.net/v1/disk/resources
 ? path=<path to the resource to delete>
 & [permanently=<whether to permanently delete the resource>]
 & [fields=<properties to include in the response>]
Query parameters
path *

The path to the resource to delete. For example, $2Ffoo%2Fphoto.png

The path in the parameter value should be URL-encoded.

permanently

The flag for permanent deletion. Supported values:

  • false — The deleted file or folder is moved to the Trash (used by default).
  • true — The file or folder is deleted without being put in the Trash.
fields

List of JSON keys to include in the response. Keys that are not included in this list will be discarded when forming the response. If the parameter is omitted, the response is returned in full, without discarding anything.

Key names should be comma-separated, and embedded keys should be separated by dots. For example: name, _embedded. items. path.

*  Required

Response format

If the request was processed without errors, the API composes the response body depending on the type of the specified resource. The response for an empty folder or file is different from the response for a non-empty folder. (If the request caused an error, a relevant response code is returned, with the response body featuring the error description.)

File or empty folder

The API responds with the code 204 No content (the resource was successfully deleted) without a response body.

Non-empty folder

Deleting a non-empty folder can take an unknown amount of time, so the API responds with the code 202 Accepted (the deletion process has started).

Applications must track the status of requested operations. The Yandex.Disk API returns the link to the status of the operation started by the request. The link is located in the Link object in the response body.

Sample response:

{  "href": "https://cloud-api.yandex.net/v1/disk/operations?id=d80c269ce4eb16c0207f0a15t4a31415313452f9e950cd9576f36b1146ee0e42",  "method": "GET",  "templated": false}
Response elements
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. Possible values:

  • “true” — URL template. Before sending a request to this address, put the desired parameter values in place of the values in curly brackets.
  • “false” — The URL can be requested without changes.