> 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 new stream

POST https://api.fastpix.com/v1/live/streams
Content-Type: application/json

Creates a new RTMPS or SRT live stream in FastPix. When you create a stream, FastPix generates a unique `streamKey` and `srtSecret` that you can use with broadcasting software such as OBS to connect to FastPix RTMPS or SRT servers. Use SRT for live streaming in unstable network conditions, as it provides error correction and encryption for a more reliable and secure broadcast.Leverage SRT for live streaming in environments with unstable networks, taking advantage of its error correction and encryption features for a resilient and secure broadcast.How it works1) Send a `POST` request to this endpoint. You can configure the stream settings, including `metadata` (such as stream name and description), `reconnectWindow` (in case of disconnection), and privacy options (`public` or `private`).

2) FastPix returns the stream details for both RTMPS and SRT configurations. These keys and IDs from the stream details are essential for connecting the broadcasting software to FastPix’s servers and transmitting the live stream to viewers.

3) After the live stream is created, FastPix sends a `POST` request to your specified webhook endpoint with the event video.live\_stream.created.**Example:**Imagine a gaming platform that allows users to live stream gameplay directly from their dashboard. The API creates a new stream, provides the necessary stream key, and sets it to "private" so that only specific viewers can access it.Related guide: How to live stream

Reference: https://fastpix.com/docs/live-stream-api/start-live-stream/create-new-stream

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

### Body (application/json)

This endpoint expects a CreateLiveStreamRequest.

- `playbackSettings` (playbackSettings, required) — Displays the result of the playback settings.
- `inputMediaSettings` (CreateLiveStreamRequestInputMediaSettings, required) — Contains configuration details for input media settings.

## Response

### 201

Stream created successfully

- `success` (boolean, optional) — Shows the request status. Returns true for success and false for failure.
- `data` (CreateLiveStreamResponseDTO, optional) — Displays the result of the request.

## Types

### playbackSettings

Displays the result of the playback settings.

- `accessPolicy` (enum, optional, default: public) — Basic access policy for media content
  - Allowed values: `public`, `private`
- `accessRestrictions` (PlaybackSettingsAccessRestrictions, optional) — Optional domain and user-agent access restrictions applied to the stream's playback ID.

### CreateLiveStreamRequestInputMediaSettings

Contains configuration details for input media settings.

- `maxResolution` (enum, optional, default: 1080p) — Defines the maximum resolution for encoding, storage, and playback of the live stream.
  - Allowed values: `1080p`, `720p`, `480p`
- `reconnectWindow` (integer, optional, default: 60) — Time period (in seconds) FastPix waits to reconnect before ending the stream when disconnected.
- `mediaPolicy` (enum, optional, default: public) — Basic access policy for media content
  - Allowed values: `public`, `private`
- `metadata` (map from string to string, optional) — Custom key–value pairs for tagging livestreams. Allows up to 10 entries with a maximum of 255 characters each.
- `enableDvrMode` (boolean, optional) — Enables DVR (Digital Video Recorder) functionality, allowing viewers to pause, rewind, and resume live playback.
- `enableRecording` (boolean, optional, default: true) — Controls whether the livestream is recorded to a VOD asset (Live-to-VOD). When set to true (default), FastPix records and stores the livestream for on-demand viewing. When set to false, the livestream is not recorded.

### CreateLiveStreamResponseDTO

Displays the result of the request.

- `streamId` (string, optional) — Upon creating a new live stream, FastPix assigns a unique identifier to the stream.
- `streamKey` (string, optional) — A unique stream key is generated for streaming, allowing the user to start streaming on any third-party platform using this key.
- `srtSecret` (string, optional) — A secret used for securing the SRT stream. This ensures that only authorized users can access the stream.
- `trial` (boolean, optional) — FastPix allows for a to trial the live stream for free. The duration of trial streams is five minutes. After five minutes of activity, the trial stream is turned off, and the recorded asset is removed after a day.
- `status` (string, optional) — The current live stream status can be one of four values:Idle, Preparing, Active or Disabled.The Idle status signifies that there isn"t a broadcast in progress.The preparing status indicates that the stream is getting prepared. while, the Active status indicates that a broadcast is currently in progress. The Disabled status means that no more RTMPS streams can be published.
- `maxResolution` (string, optional) — Max resolution can be used to control the maximum resolution your media is encoded, stored, and streamed at.
- `maxDuration` (integer, optional) — The maximum duration in seconds that a live stream can have before it ends the stream.
- `createdAt` (datetime, optional) — It is the moment when the stream was created Time the media was generated, defined as a localDateTime (UTC Time).
- `reconnectWindow` (integer, optional, default: 60) — In case the software streaming the live, gets disrupted for any reason and gets disconnected from FastPix, the reconnect window specifies the time span FastPix will wait before ending the stream. Before starting the stream, you can set the reconnect window time which is up to 1800 seconds.
- `enableRecording` (boolean, optional) — When set to true, the livestream will be recorded and stored for later viewing purposes. If set to false, the livestream will not be recorded.
- `enableDvrMode` (boolean, optional) — Enables DVR (Digital Video Recorder) functionality for the live stream. When set to true, viewers can pause, rewind, and resume playback during the live broadcast. This allows time-shifted viewing of the stream while it is still ongoing.
- `mediaPolicy` (string, optional) — Determines whether the recorded stream should be publicly accessible or private in Live to VOD (Video on Demand).
- `metadata` (map from string to string, optional) — You can search for videos with specific key value pairs using metadata, when you tag a video in "key":"value"s pairs. Dynamic metadata allows you to define a key that allows any value pair. You can have maximum of 255 characters and upto 10 entries are allowed.
- `lowLatency` (boolean, optional) — Enables low-latency streaming mode to reduce playback delay.
- `closedCaptions` (boolean, optional) — when provided true Enables closed captions for the livestream.
- `playbackIds` (list of PlaybackIdResponse, optional) — A collection of Playback ID objects utilized for crafting HLS playback urls.
- `srtPlaybackResponse` (SrtPlaybackResponse, optional) — This object contains the livestream playback response details for SRT Protocol

### PlaybackSettingsAccessRestrictions

Optional domain and user-agent access restrictions applied to the stream's playback ID.

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

### PlaybackIdResponse

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

- `id` (string, optional) — Unique identifier for the playbackId
- `accessPolicy` (string, optional) — Determines if access to the streamed content is kept private or available to all.
- `accessRestrictions` (PlaybackIdResponseAccessRestrictions, 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.

### SrtPlaybackResponse

This object contains the livestream playback response details for SRT Protocol

- `srtPlaybackStreamId` (string, optional) — A unique identifier for the SRT playback stream. This ID is used to distinguish between different playback streams
- `srtPlaybackSecret` (string, optional) — A playback secret used for securing the SRT playback stream. This ensures that only authorized users can access the playback

### PlaybackSettingsAccessRestrictionsDomains

Restrictions based on the originating domain of a request.

- `defaultPolicy` (enum, optional) — Policy action type
  - Allowed values: `allow`, `deny`
- `allow` (list of string, optional) — Domains explicitly allowed access (max 25). Only effective when defaultPolicy is "deny".
- `deny` (list of string, optional) — Domains explicitly blocked (max 25). Only effective when defaultPolicy is "allow".

### PlaybackSettingsAccessRestrictionsUserAgents

Restrictions based on the user agent.

- `defaultPolicy` (enum, optional) — Policy action type
  - Allowed values: `allow`, `deny`
- `allow` (list of string, optional) — User agents explicitly allowed access (max 25). Only effective when defaultPolicy is "deny".
- `deny` (list of string, optional) — User agents explicitly blocked (max 25). Only effective when defaultPolicy is "allow".

### PlaybackIdResponseAccessRestrictions

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` (PlaybackIdResponseAccessRestrictionsDomains, optional) — Restrictions based on the originating domain of a request (for example, whether requests from certain websites are allowed or blocked).
- `userAgents` (PlaybackIdResponseAccessRestrictionsUserAgents, optional) — Restrictions based on the user agent (typically a string sent by browsers or bots identifying themselves).

### PlaybackIdResponseAccessRestrictionsDomains

Restrictions based on the originating domain of a request (for example, whether requests from certain websites are 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. Only effective when defaultPolicy is "deny".
- `deny` (list of string, optional) — A list of domains that are explicitly blocked from accessing the resource. Only effective when defaultPolicy is "allow".

### PlaybackIdResponseAccessRestrictionsUserAgents

Restrictions based on the user agent (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. Only effective when defaultPolicy is "deny".
- `deny` (list of string, optional) — A list of specific user agents that are blocked. Only effective when defaultPolicy is "allow".

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "success": true,
  "data": {
    "streamId": "fa7f8c0950ea48ebcc5ef9de8c23deaa",
    "streamKey": "3dc5d7641f918baa083a5c52a5bd9cbckfa7f8c0950ea48ebcc5ef9de8c23deaa",
    "srtSecret": "c51739512d0088d98a46925c9b74c73akfa7f8c0950ea48ebcc5ef9de8c23deaa",
    "trial": false,
    "status": "idle",
    "maxResolution": "1080p",
    "maxDuration": 28800,
    "createdAt": "2024-10-15T08:48:31.551351Z",
    "reconnectWindow": 60,
    "enableRecording": true,
    "enableDvrMode": true,
    "mediaPolicy": "public",
    "metadata": {
      "livestream_name": "fastpix_livestream"
    },
    "lowLatency": true,
    "closedCaptions": false,
    "playbackIds": [
      {
        "id": "4e43ec52-4775-4f68-a3ff-a57d8a59bba8",
        "accessPolicy": "public",
        "accessRestrictions": {
          "domains": {
            "defaultPolicy": "allow",
            "allow": [],
            "deny": []
          },
          "userAgents": {
            "defaultPolicy": "allow",
            "allow": [],
            "deny": []
          }
        }
      }
    ],
    "srtPlaybackResponse": {
      "srtPlaybackStreamId": "playfa7f8c0950ea48ebcc5ef9de8c23deaa",
      "srtPlaybackSecret": "490e707dd4d165c9e38d261b252f9457kfa7f8c0950ea48ebcc5ef9de8c23deaa"
    }
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.fastpix.com/v1/live/streams"

payload = {}
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/live/streams';
const credentials = btoa("<username>:<password>");

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

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/live/streams"

	payload := strings.NewReader("{}")

	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/live/streams")

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 = "{}"

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/live/streams")
  .basicAuth("<username>", "<password>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.fastpix.com/v1/live/streams', [
  'body' => '{}',
  '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/live/streams");
client.Authenticator = new HttpBasicAuthenticator("<username>", "<password>");
var request = new RestRequest(Method.POST);

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

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.fastpix.com/v1/live/streams")! 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()
```