Skip to content
DocumentationAPI Reference

Save Tracks for Current User

me().tracks().save(TrackSaveParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
PUT/me/tracks

Save one or more tracks to the current user's 'Your Music' library.

ParametersExpand Collapse
params: TrackSaveParams
ids: List<String>

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 timestamped_ids is present in the body, any IDs listed in the query parameters (deprecated) or the ids field in the body will be ignored.

published: Optional<Boolean>

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

timestampedIds: Optional<List<TimestampedId>>

A JSON array of objects containing track IDs with their corresponding timestamps. Each object must include a track ID and an added_at timestamp. This allows you to specify when tracks were added to maintain a specific chronological order in the user's library.
A maximum of 50 items can be specified in one request. Note: if the timestamped_ids is present in the body, any IDs listed in the query parameters (deprecated) or the ids field in the body will be ignored.

id: String

The Spotify ID for the track.

addedAt: LocalDateTime

The timestamp when the track was added to the library. Use ISO 8601 format with UTC timezone (e.g., 2023-01-15T14:30:00Z). You can specify past timestamps to insert tracks at specific positions in the library's chronological order. The API uses minute-level granularity for ordering, though the timestamp supports millisecond precision.

formatdate-time

Save Tracks for Current User

package dev.cjav.spotted.example

import dev.cjav.spotted.client.SpottedClient
import dev.cjav.spotted.client.okhttp.SpottedOkHttpClient
import dev.cjav.spotted.models.me.tracks.TrackSaveParams

fun main() {
    val client: SpottedClient = SpottedOkHttpClient.fromEnv()

    val params: TrackSaveParams = TrackSaveParams.builder()
        .addId("string")
        .build()
    client.me().tracks().save(params)
}
Returns Examples