# Update playlist items
URL: https://musicapi.com/docs/reference/move-playlist-items.md

`PUT https://api.musicapi.com/api/{integrationUserUUID}/playlists/{playlistId}/items`

Section: Read and write a user's library.
Product: MusicAPI Core.
Auth: Basic, DevToken, DocsSession (any one of them). Use Basic with your Client ID and Client Secret from your server only.

[Check which services support updating playlist items](/docs/get-started/services-and-features)


Modify the order of items within a user's playlist based on the parameters provided in the request body. The reordering process starts from the position specified by `rangeStart` and encompasses the next `rangeLength` items. The destination for these reordered items is determined by the `insertBefore` property (starts with 0). 

Examples: 
- To move the first two items to the end of a playlist containing 10 items, set `rangeStart` as 0, `rangeLength` to 2 and `insertBefore` as 10.
- To move the last item to the start of the playlist containing 10 items, set `rangeStart` to 9, `rangeLength` to 1  and `insertBefore` to 0.

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `integrationUserUUID` | uuid | yes | The connected user: the `integrationUserUUID` from the sign-in callback. |
| `playlistId` | string | yes | ID of the playlist |

## Request body

`application/json`, required.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `rangeStart` | number | yes | The position of the first item to be reordered |
| `rangeLength` | number | yes | The amount of items to be reordered |
| `insertBefore` | number | yes | The position where the items should be inserted |

## Response 200

ok

## Errors

- 404: Your account has no connected user with this uuid, or the item does not exist.
- 412: The user must sign in again (`IntegrationUserNotAuthenticated`).
- 429: Too many requests. Wait for the seconds in `Retry-After`.

## Example

```bash
curl -X PUT "https://api.musicapi.com/api/{integrationUserUUID}/playlists/{playlistId}/items" \
  -u "$MUSICAPI_CLIENT_ID:$MUSICAPI_CLIENT_SECRET" \
  -H "Content-Type: application/json" \
  -d '{"rangeStart":1,"rangeLength":3,"insertBefore":10}'
```
