Emptying Trash

Files that were moved to Trash can be permanently deleted. 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 Trash, you can specify its path in a delete request.

Request format

Use the DELETE method to send the delete request. If the request doesn't indicate a specific resource, Trash is cleared completely.

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

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

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

Response format

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

  • If the request is processed without errors, the API returns the 204 No Content code.

  • If the operation has started but not yet finished, Yandex Disk returns the 202 Accepted code.

    Apps must track the status of requested operations. Yandex Disk returns a link to the status of the requested operation within the Link object in the response body.

    Sample response:

    {
    "href": "https://cloud-api.yandex.net/v1/disk/operations?id=33ca7d03ab21ct41b4a40182e78d828a3f8b72cdb5f4c0e94cc4b1449a63a2fe",
    "method": "GET",
    "templated": false
    }
    

    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. 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.

If the request caused an error, the relevant response code is returned, and the response body contains an error description.

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

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