Cleaning the Trash

Files that have been moved to the Trash can be permanently deleted. The Trash is considered a folder on Yandex.Disk, so doing this will increase the space available on Yandex.Disk.

To delete a specific file from the Trash, you can indicate the path to it in a delete request.

Request format

Use the DELETE method to send the delete request. If the request does not indicate a specific resource, the Trash is cleared completely.

https://cloud-api.yandex.net/v1/disk/trash/resources
 ? [path=<path to the resource to delete>]
Query parameters
path

The path to the resource to delete is relative to the Trash root directory. For example, %2Fbar%2Fphoto.png. If this parameter isn't set, the Trash is emptied.

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

Response format

Clearing the Trash may require some time. Depending on the operation status, the Yandex.Disk server returns one of two responses:

  • If the request was processed without errors at this time, the API responds with the code 204 No Content.

  • If the clear operation was started but has not yet finished, Yandex.Disk responds with the code 202 Accepted.

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

    Sample response:

    {  "href": "https://cloud-api.yandex.net/v1/disk/operations?id=33ca7d03ab21ct41b4a40182e78d828a3f8b72cdb5f4c0e94cc4b1449a63a2fe",  "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.

If the request caused an error, a relevant response code is returned, with the response body featuring the error description.