Save one or more tracks to the current user’s “Your Music” library.

Endpoint

PUT https://api.spotify.com/v1/me/tracks

Request Parameters

Note that the Spotify IDs of the tracks can be passed either as a JSON array in the request body or as a list in the query string. A track can only be saved once; duplicate IDs are ignored.

Header field
Value
AuthorizationRequired. A valid access token from the Spotify Accounts service: see the Web API Authorization Guide for details.

Modification of the current user's "Your Music" collection requires authorization of the user-library-modify scope.
Content-TypeRequired if the IDs are passed in the request body, otherwise ignored. The content type of the request body: application/json

Query argument
Value
ids
Optional. A comma-separated list of the Spotify IDs. For example: ids=4iV5W9uYEdYUVa79Axb7Rh,1301WleyT98MSxVHPZCA6M. Maximum: 50 IDs.

Request body data
Value typeValue
array of Spotify ID stringsOptional. A JSON array of the Spotify IDs. For example:
["4iV5W9uYEdYUVa79Axb7Rh", "1301WleyT98MSxVHPZCA6M"]

A maximum of 50 items can be specified in one request. Note: if the ids parameter is present in the query string, any IDs listed here in the body will be ignored.

Response Format

On success, the HTTP status code in the response header is 200 OK. On error, the header status code is an error code and the response body contains an error object. Trying to add a track when you do not have the user’s authorization, or when you have over 10.000 tracks in Your Music, returns error 403 Forbidden.

Example (save the request body’s tracks to “Your Music”)

Note that cURL requires quotation marks within the JSON data to be escaped, for example. \"4iV5W9uYEdYUVa79Axb7Rh\".
curl -i -X PUT "https://api.spotify.com/v1/me/tracks" -H "Authorization: Bearer {your access token}" -H "Content-Type: application/json" --data "[\"4iV5W9uYEdYUVa79Axb7Rh\", \"1301WleyT98MSxVHPZCA6M\"]"
HTTP/1.1 200 Success

Try it in our Web API Console