Replace all the tracks in a playlist, overwriting its existing tracks. This powerful request can be useful for replacing tracks, re-ordering existing tracks, or clearing the playlist.
Endpoints
PUT https://api.spotify.com/v1/users/{user_id}/playlists/{playlist_id}/tracks
PUT https://api.spotify.com/v1/users/{user_id}/playlists/{playlist_id}/tracks?uris={uris}
Request Parameters
| Path parameter | Value |
|---|---|
| user_id | The user's Spotify user ID. |
| playlist_id | The Spotify ID for the playlist. |
Header field | Value |
|---|---|
| Authorization | Required. A valid access token from the Spotify Accounts service: see the Web API Authorization Guide for details. The access token must have been issued on behalf of the user. Setting tracks in the current user's public playlists requires authorization of the playlist-modify-public scope; setting tracks in the current user's private playlist (including collaborative playlists) requires the playlist-modify-private scope. See Using Scopes. |
| Content-Type | Required if URIs are passed in the request body, otherwise ignored. The content type of the request body: application/json |
The Spotify URIs of the tracks to set can be passed either as a JSON array in the request body or as a list in the query string. The request can only accept a maximum of 100 tracks; any additional tracks will need to be added using the “Add Tracks to a Playlist” endpoint.
| Query parameter | Value type | Value |
|---|---|---|
| uris | list of Spotify URIs | Optional. A comma-separated list of Spotify track URIs to set. For example: uris=spotify:track:4iV5W9uYEdYUVa79Axb7Rh,A maximum of 100 tracks can be set in one request. |
| Request body data | Value type | Value |
|---|---|---|
| uris | array of Spotify URI strings | Optional. A JSON array of the Spotify track URIs to set. For example: {"uris": ["spotify:track:4iV5W9uYEdYUVa79Axb7Rh", "spotify:track:1301WleyT98MSxVHPZCA6M"]}Currently, a maximum of 100 tracks can be set. Note: if the uris parameter is present in the query string, any URIs listed here in the body will be ignored. |
Response Format
On success, the HTTP status code in the response header is 201 Created. On error, the header status code is an error code, the response body contains an error object, and the existing playlist is unmodified. Trying to set a track when you do not have the user’s authorization returns error 403 Forbidden.
Example (append the request body’s tracks to a playlist)
Note that cURL requires quotation marks within the JSON data to be escaped, for example.
\"spotify:track:4iV5W9uYEdYUVa79Axb7Rh\".curl -i -X PUT "https://api.spotify.com/v1/users/thelinmichael/playlists/0vXtvEeftmc2aVQD9QBWrQ/tracks" -H "Authorization: Bearer {your access token}" -H "Content-Type:application/json" --data "{ \"uris\" : [\"spotify:track:4iV5W9uYEdYUVa79Axb7Rh\", \"spotify:track:1301WleyT98MSxVHPZCA6M\" ] }"
HTTP/1.1 201 Created