Delete an Item from a Playlist
Each user on a Plex server can create their own playlists. A playlist can contain either videos, music, or photos, and can't be shared with other users. There are smart and non-smart playlists. This API command will delete a single item from a non-smart playlist.
URL
DELETE http://{ip_address}:32400/playlists/{id}/items/{item_id}?X-Plex-Token={plex_token}
Parameters
Name | Description |
---|---|
ip_address | The IP address of the Plex Media server. |
plex_token | The Plex user token. |
id | The key associated with a playlist. This key can be found by calling the view playlists for a user API command and getting the value in the ratingsKey attribute. |
item_id | The ID associated with the media item in the playlist. Can be found by calling the View Items in a Playlist command and getting the playlistItemID attribute value. |
Return Status
HTTP Code | Description |
---|---|
200 | Success - The request was successful. |
401 | Unauthorized - The Plex token provided is not valid. |
404 | Not found - The playlist or media item ID is not valid. |
Response
XML string value that provides details about the playlist for the item that was just added. An example of the XML return value is shown below:
<MediaContainer size="1" leafCountAdded="1" leafCountRequested="1"> <Playlist ratingKey="289273" key="/playlists/289273/items" guid="com.plexapp.agents.none://3d6e93e8-3217-4f29-ad50-bd389abca279" type="playlist" title="War Movies" summary="" smart="0" playlistType="video" composite="/playlists/289273/composite/1698191973" duration="12356000" leafCount="2" addedAt="1684802334" updatedAt="1698191973"></Playlist> </MediaContainer>
The XML return provides information the playlist that contains the added item. The root is the MediaContainer
element. This element contains a single attribute indicating that one playlist has been returned from the server.
Attribute | Description |
---|---|
size | The number of playlists returned. |
Within the MediaContainer
there is one Playlist
child element. The Playlist
element contains information on the new playlist on the Plex server.
Attribute | Description |
---|---|
ratingKey | A key associated with the playlist. |
key | The relative URL of the items in the playlist. This URL returns information about the items in the playlist. |
guid | The unique identifier comprised of the Plex agent and playlist identifier for the agent. |
type | The type of media. |
title | The title of the playlist. |
summary | A description of the playlist. This can be changed by editing the playlist from within Plex after it has been created. |
smart | 1 - playlist is a smart playlist. 0 - playlist is not a smart playlist. |
playlistType | video - playlist contains videos/movies. audio - playlist contains audio/music. photo - playlist contains photos. |
composite | The URL of the image used to represent the playlist. |
duration | The total duration, in milliseconds, of the number of items in the playlist. This value doesn't exist for photo playlists. |
leafCount | Number of items in the playlist. |
addedAt | The date and time, in Unix time, the playlist was added to the library. |
updatedAt | The date and time in epoch time, the playlist was updated in the library. |
Remarks
Library key parameter
The Library Key
parameter value can be found if you access the Plex server from the Web app.
When you hover over any item - movie, TV show, music, photo, etc. there will be a key
parameter in the URL. That key value is the value you will use for the Library Key
parameter.
The value is easy to find in the URL of the item. It has the structure /library/metadata/{item_id}
. You will use the entire value of the key
parameter from the media item URL.
Examples
curl -X DELETE http://{ip_address}:32400/playlists/{id}/items/{item_id}?X-Plex-Token={plex_token}
import requests plex_url = http://{ip_address}:32400/playlists/{id}/items/{item_id}?X-Plex-Token={plex_token} response = requests.delete(plex_url) print(response.text)
$response = Invoke-RestMethod 'http://{ip_address}:32400/playlists/{id}/items/{item_id}?X-Plex-Token={plex_token}' -Method 'DELETE' Write-Output $response