> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://fastpix.com/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://fastpix.com/docs/_mcp/server.

# Change media order in a playlist by ID

PUT https://api.fastpix.com/v1/on-demand/playlists/{playlistId}/media
Content-Type: application/json

This endpoint allows you to change the order of media items within a playlist. By passing the complete list of media IDs in the desired sequence, the playlist's play order is updated accordingly.
#### How it works

 - When a user sends a PUT request to this endpoint with the `playlistId` as path parameter and the reordered list of all media IDs in the request body, FastPix updates the playlist to reflect the new media sequence and returns the updated playlist details.

#### Example
An e-learning platform rearranges the "Beginner Python Series" playlist by submitting a reordered list of media IDs. The playlist now follows the new sequence, providing learners with a better structured learning path.

Reference: https://fastpix.com/docs/video-on-demand-api/playlist/change-media-order-in-playlist

## Authentication

- `Authorization` header (basic auth, required) — FastPix APIs are secured with Basic Authentication. Use your Access Token ID as the username and Secret Key as the password in the Authorization header of each API request. * Username: Access Token ID * Password: Secret Key Activate your FastPix account to generate your API credentials. See the guide here

## Request

### Path parameters

- `playlistId` (string, required) — The unique id of the playlist you want to perform the operation on.

### Body (application/json)

This endpoint expects a MediaIdsRequest.

- `mediaIds` (list of string, required)

## Response

### 200

Added media to playlist successfully

- `success` (boolean, required) — Shows the request status. Returns true for success and false for failure.
- `data` (PlaylistByIdResponseData, required)

## Types

### PlaylistByIdResponseData

- `type`: `manual` (manual)
  - `createdAt` (datetime, optional) — Timestamp of playlist creation.
  - `description` (string, optional) — Description of the playlist set by the user.
  - `id` (string, optional) — The unique id of the playlist
  - `mediaCount` (integer, optional) — No. of media present in the playlist
  - `mediaList` (list of PlaylistByIdResponseMediaListItem, optional)
  - `name` (string, optional) — The name of the playlist set by the user
  - `referenceId` (string, optional) — Unique string value assigned by user to the playlist.
  - `updatedAt` (datetime, optional) — Playlist's most recent update timestamp.
  - `workspaceId` (string, optional) — The unique id of the workspace in which the playlist is present.
- `type`: `smart` (smart)
  - `metadata` (PlaylistByIdResponseMetadata, required) — Required when the playlist type is `smart`. Media created between `startDate` and `endDate` of `createdDate` is added. Optionally, you can include media based on `updatedDate`.
  - `playOrder` (enum, required) — Determines the insertion order of media into playlist.
    - Allowed values: `createdDate ASC`, `createdDate DESC`
  - `createdAt` (datetime, optional) — Timestamp of playlist creation.
  - `description` (string, optional) — Description of the playlist set by the user.
  - `id` (string, optional) — The unique id of the playlist
  - `mediaCount` (integer, optional) — No. of media present in the playlist
  - `mediaList` (list of PlaylistByIdResponseMediaListItem, optional)
  - `name` (string, optional) — The name of the playlist set by the user
  - `referenceId` (string, optional) — Unique string value assigned by user to the playlist.
  - `updatedAt` (datetime, optional) — Playlist's most recent update timestamp.
  - `workspaceId` (string, optional) — The unique id of the workspace in which the playlist is present.

### PlaylistByIdResponseMediaListItem

- `createdAt` (datetime, optional) — Timestamp of media creation in the workspace.
- `creatorId` (string, optional, nullable) — Creator ID of the media.
- `duration` (double, optional) — Duration of the media in seconds.
- `id` (string, optional) — unique id of the particular media.
- `sourceResolution` (string, optional) — source resolution of the media.
- `status` (string, optional) — status of the media, only media with ready status is added to playlist.
- `thumbnail` (string, optional) — thumbnail for the particular media.
- `title` (string, optional, nullable) — Title of the media.

### PlaylistByIdResponseMetadata

Required when the playlist type is `smart`. Media created between `startDate` and `endDate` of `createdDate` is added. Optionally, you can include media based on `updatedDate`.

- `createdDate` (DateRange, optional) — Date range with start and end dates.
- `updatedDate` (DateRange, optional) — Date range with start and end dates.

### DateRange

Date range with start and end dates.

- `startDate` (string, optional)
- `endDate` (string, optional)

## Examples

**Request**

```json
{
  "mediaIds": [
    "a1cd180e-f9b5-4e99-9d44-b9c9baabad89",
    "245800c3-7b73-47d9-a201-e961260dcb30",
    "41316aac-5396-4278-8f44-08d5f2495b12"
  ]
}
```

**Response**

```json
{
  "success": true,
  "data": {
    "type": "smart",
    "metadata": {
      "createdDate": {
        "startDate": "2024-12-11",
        "endDate": "2024-12-12"
      },
      "updatedDate": {
        "startDate": "2024-12-11",
        "endDate": "2024-12-12"
      }
    },
    "playOrder": "createdDate ASC",
    "createdAt": "2025-06-05T09:10:30.655275Z",
    "description": "This Playlist contains videos from December 2024.",
    "id": "46d5fce1-683a-457f-86d7-c048bb429505",
    "mediaCount": 3,
    "mediaList": [
      {
        "createdAt": "2025-05-27T09:37:52.445936Z",
        "creatorId": "FastPix@14612",
        "duration": 10.5,
        "id": "a1cd180e-f9b5-4e99-9d44-b9c9baabad89",
        "sourceResolution": "1080p",
        "status": "Ready",
        "thumbnail": "https://venus-images.fastpix.dev/bed25609-1887-4c49-91a5-5c6b1edeb1a2/thumbnail.png",
        "title": "Media 1"
      },
      {
        "createdAt": "2025-04-04T13:26:23.507284Z",
        "creatorId": "FastPix@14612",
        "duration": 10.5,
        "id": "245800c3-7b73-47d9-a201-e961260dcb30",
        "sourceResolution": "1080p",
        "status": "Ready",
        "thumbnail": "https://mercury-images.fastpix.dev/3c6ceeea-d24b-487f-9dd0-5a16148b5d46/thumbnail.png",
        "title": "Media 2"
      },
      {
        "createdAt": "2025-04-04T13:26:12.552840Z",
        "creatorId": "FastPix@14612",
        "duration": 10.5,
        "id": "41316aac-5396-4278-8f44-08d5f2495b12",
        "sourceResolution": "1080p",
        "status": "Ready",
        "thumbnail": "https://mercury-images.fastpix.dev/8989d0d3-5c5b-41b2-89d5-df6094e6093f/thumbnail.png",
        "title": "Media 3"
      }
    ],
    "name": "My Playlist",
    "referenceId": "122q",
    "updatedAt": "2025-06-05T12:23:47.096690Z",
    "workspaceId": "d760b903-86ef-44d6-9b73-334130e0cf2d"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.fastpix.com/v1/on-demand/playlists/playlistId/media"

payload = { "mediaIds": ["a1cd180e-f9b5-4e99-9d44-b9c9baabad89", "245800c3-7b73-47d9-a201-e961260dcb30", "41316aac-5396-4278-8f44-08d5f2495b12"] }
headers = {
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers, auth=("<username>", "<password>"))

print(response.json())
```

```javascript
const url = 'https://api.fastpix.com/v1/on-demand/playlists/playlistId/media';
const credentials = btoa("<username>:<password>");

const options = {
  method: 'PUT',
  headers: {
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/json'
  },
  body: '{"mediaIds":["a1cd180e-f9b5-4e99-9d44-b9c9baabad89","245800c3-7b73-47d9-a201-e961260dcb30","41316aac-5396-4278-8f44-08d5f2495b12"]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.fastpix.com/v1/on-demand/playlists/playlistId/media"

	payload := strings.NewReader("{\n  \"mediaIds\": [\n    \"a1cd180e-f9b5-4e99-9d44-b9c9baabad89\",\n    \"245800c3-7b73-47d9-a201-e961260dcb30\",\n    \"41316aac-5396-4278-8f44-08d5f2495b12\"\n  ]\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.SetBasicAuth("<username>", "<password>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.fastpix.com/v1/on-demand/playlists/playlistId/media")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request.basic_auth("<username>", "<password>")
request["Content-Type"] = 'application/json'
request.body = "{\n  \"mediaIds\": [\n    \"a1cd180e-f9b5-4e99-9d44-b9c9baabad89\",\n    \"245800c3-7b73-47d9-a201-e961260dcb30\",\n    \"41316aac-5396-4278-8f44-08d5f2495b12\"\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api.fastpix.com/v1/on-demand/playlists/playlistId/media")
  .basicAuth("<username>", "<password>")
  .header("Content-Type", "application/json")
  .body("{\n  \"mediaIds\": [\n    \"a1cd180e-f9b5-4e99-9d44-b9c9baabad89\",\n    \"245800c3-7b73-47d9-a201-e961260dcb30\",\n    \"41316aac-5396-4278-8f44-08d5f2495b12\"\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.fastpix.com/v1/on-demand/playlists/playlistId/media', [
  'body' => '{
  "mediaIds": [
    "a1cd180e-f9b5-4e99-9d44-b9c9baabad89",
    "245800c3-7b73-47d9-a201-e961260dcb30",
    "41316aac-5396-4278-8f44-08d5f2495b12"
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<username>', '<password>'],
]);

echo $response->getBody();
```

```csharp
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://api.fastpix.com/v1/on-demand/playlists/playlistId/media");
client.Authenticator = new HttpBasicAuthenticator("<username>", "<password>");
var request = new RestRequest(Method.PUT);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"mediaIds\": [\n    \"a1cd180e-f9b5-4e99-9d44-b9c9baabad89\",\n    \"245800c3-7b73-47d9-a201-e961260dcb30\",\n    \"41316aac-5396-4278-8f44-08d5f2495b12\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let credentials = Data("<username>:<password>".utf8).base64EncodedString()

let headers = [
  "Authorization": "Basic \(credentials)",
  "Content-Type": "application/json"
]
let parameters = ["mediaIds": ["a1cd180e-f9b5-4e99-9d44-b9c9baabad89", "245800c3-7b73-47d9-a201-e961260dcb30", "41316aac-5396-4278-8f44-08d5f2495b12"]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.fastpix.com/v1/on-demand/playlists/playlistId/media")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```