Skip to content
DocumentationAPI Reference

Add Items to Playlist

client.Playlists.Tracks.Add(ctx, playlistID, body) (*PlaylistTrackAddResponse, error)
POST/playlists/{playlist_id}/tracks

Add one or more items to a user's playlist.

ParametersExpand Collapse
playlistID string

The Spotify ID of the playlist.

body PlaylistTrackAddParams
Position param.Field[int64]optional

The position to insert the items, a zero-based index. For example, to insert the items in the first position: position=0 ; to insert the items in the third position: position=2. If omitted, the items will be appended to the playlist. Items are added in the order they appear in the uris array. For example: {"uris": ["spotify:track:4iV5W9uYEdYUVa79Axb7Rh","spotify:track:1301WleyT98MSxVHPZCA6M"], "position": 3}

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

Uris param.Field[[]string]optional

A JSON array of the Spotify URIs to add. For example: {"uris": ["spotify:track:4iV5W9uYEdYUVa79Axb7Rh","spotify:track:1301WleyT98MSxVHPZCA6M", "spotify:episode:512ojhOuo1ktJprKbVcKyQ"]}
A maximum of 100 items can be added in one request. Note: if the uris parameter is present in the query string, any URIs listed here in the body will be ignored.

ReturnsExpand Collapse
type PlaylistTrackAddResponse struct{…}
SnapshotID stringoptional

Add Items to Playlist

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"),
  )
  response, err := client.Playlists.Tracks.Add(
    context.TODO(),
    "3cEYpjA9oz9GiPac4AsH4n",
    spotted.PlaylistTrackAddParams{

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