Endpoints

PUT https://api.spotify.com/v1/users/{user_id}/playlists/{playlist_id}/tracks

Request Parameters

Path 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 Parameters

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,spotify:track:1301WleyT98MSxVHPZCA6M
A maximum of 100 tracks can be set in one request.

Body Parameters

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 (replace the playlist’s tracks with the tracks in the request body)

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

Try it