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>]
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:
|
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: |
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:
|
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: |
* 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}
Element | Description |
---|---|
href | URL. It may be a URL template; see the |
method | The HTTP method for requesting the URL from the |
templated | Indicates a URL template according to RFC 6570. Possible values:
|
Element | Description |
---|---|
href | URL. It may be a URL template; see the |
method | The HTTP method for requesting the URL from the |
templated | Indicates a URL template according to RFC 6570. Possible values:
|