Skip to content
DocumentationAPI Reference

Update Playlist Items

client.Playlists.Tracks.Update(ctx, playlistID, body) (*PlaylistTrackUpdateResponse, error)
PUT/playlists/{playlist_id}/tracks

Either reorder or replace items in a playlist depending on the request's parameters. To reorder items, include range_start, insert_before, range_length and snapshot_id in the request's body. To replace items, include uris as either a query parameter or in the request's body. Replacing items in a playlist will overwrite its existing items. This operation can be used for replacing or clearing items in a playlist.
Note: Replace and reorder are mutually exclusive operations which share the same endpoint, but have different parameters. These operations can't be applied together in a single request.

ParametersExpand Collapse
playlistID string

The Spotify ID of the playlist.

body PlaylistTrackUpdateParams
InsertBefore param.Field[int64]optional

The position where the items should be inserted.
To reorder the items to the end of the playlist, simply set insert_before to the position after the last item.
Examples:
To reorder the first item to the last position in a playlist with 10 items, set range_start to 0, and insert_before to 10.
To reorder the last item in a playlist with 10 items to the start of the playlist, set range_start to 9, and insert_before to 0.

Published param.Field[bool]optional

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

RangeLength param.Field[int64]optional

The amount of items to be reordered. Defaults to 1 if not set.
The range of items to be reordered begins from the range_start position, and includes the range_length subsequent items.
Example:
To move the items at index 9-10 to the start of the playlist, range_start is set to 9, and range_length is set to 2.

RangeStart param.Field[int64]optional

The position of the first item to be reordered.

SnapshotID param.Field[string]optional

The playlist's snapshot ID against which you want to make the changes.

Uris param.Field[[]string]optional
ReturnsExpand Collapse
type PlaylistTrackUpdateResponse struct{…}
SnapshotID stringoptional

Update Playlist Items

package main

import (
  "context"
  "fmt"

  "github.com/cjavdev/spotted-go"
  "github.com/cjavdev/spotted-go/option"
)

func main() {
  client := spotted.NewClient(
    option.WithAccessToken("My Access Token"),
  )
  track, err := client.Playlists.Tracks.Update(
    context.TODO(),
    "3cEYpjA9oz9GiPac4AsH4n",
    spotted.PlaylistTrackUpdateParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", track.SnapshotID)
}
{
  "snapshot_id": "abc"
}
Returns Examples
{
  "snapshot_id": "abc"
}