> Markdown versions of all pages of this connector library are available by appending `.md` to the page URL. For the full index of connectors, see [llms.txt](https://connectors.appmixer.com/llms.txt).

# Add Items To Playlist

- Component: `appmixer.spotify.core.AddItemsToPlaylist`
- Kind: Action
- Version: 1.0.0
- Visibility: Public
- Connector: [appmixer.spotify 1.0.0](https://connectors.appmixer.com/connector/appmixer.spotify/1.0.0.md)
- Component page: <https://connectors.appmixer.com/connector/appmixer.spotify/1.0.0/component/appmixer.spotify.core.AddItemsToPlaylist>

Adds tracks to a Spotify playlist, in chunks of 100 so a whole tracklist fits in one message. Accepts an array from Find Tracks or a comma / newline separated list of URIs, IDs or links.

## Input ports

### Port `in`

| Field | Type | Description |
| --- | --- | --- |
| Playlist (`playlistId`) | text | Start typing to pick one of your playlists, or enter a playlist ID, `spotify:playlist:` URI or open.spotify.com link directly. |
| Track URIs (`uris`) | textarea | The tracks to add. Accepts an array of URIs (or of Find Tracks records), or a comma / newline separated list. Each entry may be a `spotify:track:` URI, a bare track ID or an open.spotify.com link. |
| Position (`position`) | number | Zero-based index to insert the tracks at. Leave empty to append them to the end of the playlist. |
| Skip Duplicates (`skipDuplicates`) | toggle | When on, the playlist's current items are read first and any track already in it - or repeated in the input - is skipped. Costs one extra API call per 50 existing items. |

## Output ports

### Port `out`

| Field | Type | Description |
| --- | --- | --- |
| Snapshot ID (`snapshotId`) | string | - |
| Items Added (`added`) | integer | - |

## Full metadata (component.json)

```json
{
  "name": "appmixer.spotify.core.AddItemsToPlaylist",
  "label": "Add Items To Playlist",
  "description": "Adds tracks to a Spotify playlist, in chunks of 100 so a whole tracklist fits in one message. Accepts an array from Find Tracks or a comma / newline separated list of URIs, IDs or links.",
  "author": "Appmixer <info@appmixer.com>",
  "version": "1.0.0",
  "auth": {
    "service": "appmixer:spotify"
  },
  "quota": {
    "manager": "appmixer:spotify",
    "resources": "requests",
    "scope": {
      "userId": "{{userId}}"
    }
  },
  "inPorts": [
    {
      "name": "in",
      "schema": {
        "type": "object",
        "properties": {
          "playlistId": {
            "type": "string"
          },
          "uris": {
            "type": "string"
          },
          "position": {
            "type": "integer"
          },
          "skipDuplicates": {
            "type": "boolean"
          }
        },
        "required": [
          "playlistId",
          "uris"
        ]
      },
      "inspector": {
        "inputs": {
          "playlistId": {
            "type": "text",
            "index": 1,
            "label": "Playlist",
            "tooltip": "Start typing to pick one of your playlists, or enter a playlist ID, <code>spotify:playlist:</code> URI or open.spotify.com link directly.",
            "source": {
              "url": "/component/appmixer/spotify/core/ListPlaylists?outPort=out",
              "data": {
                "transform": "./ListPlaylists#toSelectArray",
                "messages": {
                  "in/outputType": "array",
                  "in/isSource": true
                }
              }
            }
          },
          "uris": {
            "type": "textarea",
            "index": 2,
            "label": "Track URIs",
            "tooltip": "The tracks to add. Accepts an array of URIs (or of Find Tracks records), or a comma / newline separated list. Each entry may be a <code>spotify:track:</code> URI, a bare track ID or an open.spotify.com link."
          },
          "position": {
            "type": "number",
            "index": 3,
            "label": "Position",
            "tooltip": "Zero-based index to insert the tracks at. Leave empty to append them to the end of the playlist."
          },
          "skipDuplicates": {
            "type": "toggle",
            "index": 4,
            "label": "Skip Duplicates",
            "defaultValue": false,
            "tooltip": "When on, the playlist's current items are read first and any track already in it - or repeated in the input - is skipped. Costs one extra API call per 50 existing items."
          }
        }
      }
    }
  ],
  "outPorts": [
    {
      "name": "out",
      "schema": {
        "type": "object",
        "properties": {
          "snapshotId": {
            "type": "string",
            "title": "Snapshot ID",
            "example": "MTgsMGRkYzcxMmQwZWMyZWU4ZmY0YjM2ZDY3ZDBmMTgyODdmYjFiZGQxNw=="
          },
          "added": {
            "type": "integer",
            "title": "Items Added",
            "example": 38
          }
        }
      }
    }
  ],
  "icon": "(data URI omitted)"
}
```
