> 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.

# Create a playback ID

POST https://api.fastpix.com/v1/on-demand/{mediaId}/playback-ids
Content-Type: application/json

You can create a new playback ID for a specific media asset. If you have already retrieved an existing `playbackId` using the Get Media by ID endpoint for a media asset, you can use this endpoint to generate a new playback ID with a specified access policy.

If you want to create a private playback ID for a media asset that already has a public playback ID, this endpoint also allows you to do so by specifying the desired access policy.

#### How it works

1. Make a `POST` request to this endpoint, replacing `<mediaId>` with the `uploadId` or `id` of the media asset.

2. Include the `accessPolicy` in the request body with `private` or `public` as the value.

3. You receive a response containing the newly created playback ID with the specified access level.

#### Example

A video streaming service generates playback IDs for each media file when users request to view specific content. The video player then uses the playback ID to stream the video.

Reference: https://fastpix.com/docs/video-on-demand-api/playback/create-media-playback-id

## 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

- `mediaId` (string, required) — The unique identifier assigned to the media when created. The value must be a valid UUID.

### Body (application/json)

This endpoint expects an object.

- `accessPolicy` (enum, required) — Access policy for media content
  - Allowed values: `public`, `private`, `drm`
- `accessRestrictions` (OnDemandMediaIdPlaybackIdsPostRequestBodyContentApplicationJsonSchemaAccessRestrictions, optional)
- `drmConfigurationId` (string, optional) — DRM configuration ID (required if accessPolicy is "drm")
- `resolution` (enum, optional) — The maximum resolution for the playback ID.
  - Allowed values: `480p`, `720p`, `1080p`, `1440p`, `2160p`

## Response

### 201

Playback ID for a media content.

- `success` (boolean, optional) — Shows the request status. Returns true for success and false for failure.
- `data` (CreatePlaybackId, optional) — A collection of Playback ID objects utilized for crafting HLS playback urls.

## Types

### OnDemandMediaIdPlaybackIdsPostRequestBodyContentApplicationJsonSchemaAccessRestrictions

- `domains` (DomainRestrictions, optional) — Restrictions based on the originating domain of a request
- `userAgents` (UserAgentRestrictions, optional) — Restrictions based on the user agent

### CreatePlaybackId

A collection of Playback ID objects utilized for crafting HLS playback urls.

- `id` (string, optional) — A unique identifier is generated by FastPix for the playbacks.
- `accessPolicy` (enum, optional) — Access policy for media content
  - Allowed values: `public`, `private`, `drm`
- `accessRestrictions` (CreatePlaybackIdAccessRestrictions, optional) — Controls access based on domains and user agents. Defines a default policy (either "allow" or "deny") and provides lists for explicitly allowed or denied domains and user agents.
- `resolution` (enum, optional) — The maximum resolution for the playback ID.
  - Allowed values: `480p`, `720p`, `1080p`, `1440p`, `2160p`

### DomainRestrictions

Restrictions based on the originating domain of a request

- `defaultPolicy` (enum, optional) — Policy action type
  - Allowed values: `allow`, `deny`
- `allow` (list of string, optional) — A list of domain names or patterns that are explicitly allowed access
- `deny` (list of string, optional) — A list of domain names or patterns that are explicitly denied access

### UserAgentRestrictions

Restrictions based on the user agent

- `defaultPolicy` (enum, optional) — Policy action type
  - Allowed values: `allow`, `deny`
- `allow` (list of string, optional) — A list of user agents that are explicitly allowed access
- `deny` (list of string, optional) — A list of user agents that are explicitly denied access

### CreatePlaybackIdAccessRestrictions

Controls access based on domains and user agents. Defines a default policy (either "allow" or "deny") and provides lists for explicitly allowed or denied domains and user agents.

- `domains` (CreatePlaybackIdAccessRestrictionsDomains, optional) — Restrictions based on the originating domain of a request (for example, whether requests from certain websites should be allowed or blocked).
- `userAgents` (CreatePlaybackIdAccessRestrictionsUserAgents, optional) — Restrictions based on the user agent (which is typically a string sent by browsers or bots identifying themselves).

### CreatePlaybackIdAccessRestrictionsDomains

Restrictions based on the originating domain of a request (for example, whether requests from certain websites should be allowed or blocked).

- `defaultPolicy` (enum, optional) — Policy action type
  - Allowed values: `allow`, `deny`
- `allow` (list of string, optional) — A list of domains that are explicitly allowed access.
- `deny` (list of string, optional) — A list of domains that are explicitly blocked from accessing the resource.

### CreatePlaybackIdAccessRestrictionsUserAgents

Restrictions based on the user agent (which is typically a string sent by browsers or bots identifying themselves).

- `defaultPolicy` (enum, optional) — Policy action type
  - Allowed values: `allow`, `deny`
- `allow` (list of string, optional) — A list of specific user agents that are allowed to access the resource.
- `deny` (list of string, optional) — A list of specific user agents that are blocked.

## Examples

**Request**

```json
{
  "accessPolicy": "public"
}
```

**Response**

```json
{
  "success": true,
  "data": {
    "id": "b331e0d8-bef4-4ad2-8760-757fdb2818b7",
    "accessPolicy": "public",
    "accessRestrictions": {
      "domains": {
        "defaultPolicy": "allow",
        "allow": [],
        "deny": []
      },
      "userAgents": {
        "defaultPolicy": "allow",
        "allow": [],
        "deny": []
      }
    },
    "resolution": "1080p"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.fastpix.com/v1/on-demand/dbb8a39a-e4a5-4120-9f22-22f603f1446e/playback-ids"

payload = { "accessPolicy": "public" }
headers = {
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.fastpix.com/v1/on-demand/dbb8a39a-e4a5-4120-9f22-22f603f1446e/playback-ids';
const credentials = btoa("<username>:<password>");

const options = {
  method: 'POST',
  headers: {
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/json'
  },
  body: '{"accessPolicy":"public"}'
};

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/dbb8a39a-e4a5-4120-9f22-22f603f1446e/playback-ids"

	payload := strings.NewReader("{\n  \"accessPolicy\": \"public\"\n}")

	req, _ := http.NewRequest("POST", 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/dbb8a39a-e4a5-4120-9f22-22f603f1446e/playback-ids")

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

request = Net::HTTP::Post.new(url)
request.basic_auth("<username>", "<password>")
request["Content-Type"] = 'application/json'
request.body = "{\n  \"accessPolicy\": \"public\"\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.post("https://api.fastpix.com/v1/on-demand/dbb8a39a-e4a5-4120-9f22-22f603f1446e/playback-ids")
  .basicAuth("<username>", "<password>")
  .header("Content-Type", "application/json")
  .body("{\n  \"accessPolicy\": \"public\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.fastpix.com/v1/on-demand/dbb8a39a-e4a5-4120-9f22-22f603f1446e/playback-ids', [
  'body' => '{
  "accessPolicy": "public"
}',
  '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/dbb8a39a-e4a5-4120-9f22-22f603f1446e/playback-ids");
client.Authenticator = new HttpBasicAuthenticator("<username>", "<password>");
var request = new RestRequest(Method.POST);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"accessPolicy\": \"public\"\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 = ["accessPolicy": "public"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.fastpix.com/v1/on-demand/dbb8a39a-e4a5-4120-9f22-22f603f1446e/playback-ids")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```