Empty Trash
When you remove media files or directories from your server and perform a scan, Plex will typically remove the items from the media library. If you have disabled Plex from automatically emptying trash after each scan, then you will have orphan items in your Plex server.
You can manually empty the trash in Plex by using this API command.
This command is the same API command used by the Empty Trash option in Plex.
URL
PUT http://{ip_address}:32400/library/sections/{id}/emptyTrash?X-Plex-Token={plex_token}
Parameters
Name | Description |
---|---|
ip_address | The IP address of the Plex Media server. |
plex_token | The Plex token. |
id | The key associated with a library. This key can be found by calling the Libraries API command. |
Return Status
HTTP Code | Description |
---|---|
200 | Success - The request was successful. |
401 | Unauthorized - The Plex token provided was not valid. |
Response
No response is returned. You will be able to see the empty trash API command run from the Plex console.
Remarks
The empty trash command will need to run for each library in your Plex server.
Examples
curl -X PUT http://{ip_address}:32400/library/sections/{id}/emptyTrash?X-Plex-Token={plex_token}
import requests plex_url = http://{ip_address}:32400/library/sections/{id}/emptyTrash?X-Plex-Token={plex_token} response = requests.put(plex_url) print(response.text)
$response = Invoke-RestMethod 'http://{ip_address}:32400/library/sections/{id}/emptyTrash?X-Plex-Token={plex_token}' -Method 'PUT' Write-Output $response