Skip to content
Start here

Create an independent livestream

client.RealtimeKit.Livestreams.NewIndependentLivestream(ctx, appID, params) (*LivestreamNewIndependentLivestreamResponse, error)
POST/accounts/{account_id}/realtime/kit/{app_id}/livestreams

Creates a livestream for the given App ID and returns ingest server, stream key, and playback URL. You can pass custom input to the ingest server and stream key, and freely distribute the content using the playback URL on any player that supports HLS/LHLS.

Security

API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
Accepted Permissions (at least one required)
Realtime AdminRealtime
ParametersExpand Collapse
appID string

The app identifier tag.

maxLength32
params LivestreamNewIndependentLivestreamParams
AccountID param.Field[string]

Path param: The account identifier tag.

maxLength32
Name param.Field[string]optional

Body param: Name of the livestream

ReturnsExpand Collapse
type LivestreamNewIndependentLivestreamResponse struct{…}
Data LivestreamNewIndependentLivestreamResponseDataoptional
ID stringoptional

The livestream ID.

Disabled booloptional

Specifies if the livestream was disabled.

IngestServer stringoptional

The server URL to which the RTMP encoder should send the video and audio data.

MeetingID stringoptional
Name stringoptional
PlaybackURL stringoptional

The web address that viewers can use to watch the livestream.

Status LivestreamNewIndependentLivestreamResponseDataStatusoptional
One of the following:
const LivestreamNewIndependentLivestreamResponseDataStatusLive LivestreamNewIndependentLivestreamResponseDataStatus = "LIVE"
const LivestreamNewIndependentLivestreamResponseDataStatusIdle LivestreamNewIndependentLivestreamResponseDataStatus = "IDLE"
const LivestreamNewIndependentLivestreamResponseDataStatusErrored LivestreamNewIndependentLivestreamResponseDataStatus = "ERRORED"
const LivestreamNewIndependentLivestreamResponseDataStatusInvoked LivestreamNewIndependentLivestreamResponseDataStatus = "INVOKED"
StreamKey stringoptional

Unique key for accessing each livestream.

Success booloptional

Create an independent livestream

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/option"
  "github.com/cloudflare/cloudflare-go/realtime_kit"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  response, err := client.RealtimeKit.Livestreams.NewIndependentLivestream(
    context.TODO(),
    "app_id",
    realtime_kit.LivestreamNewIndependentLivestreamParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
      Name: cloudflare.F("prdmmp-xhycsl"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Data)
}
{
  "data": {
    "disabled": false,
    "id": "78dd0b50-4147-4bb8-88d3-2ccc2e98bff0",
    "ingest_server": "rtmps://live.cloudflare.com:443/live/",
    "meeting_id": null,
    "name": "Livestreaming-Demo",
    "playback_url": "https://customer-s8oj0c1n5ek8ah1e.cloudflarestream.com/7de6a3fec0f9c05bf1df140950d3a237/manifest/video.m3u8",
    "status": "INVOKED",
    "stream_key": "f26566285faca6fbe2e79a73a66rsrrsrrsr3cde23a2bb7dbc6c2c1761b98f4e4"
  },
  "success": true
}
Returns Examples
{
  "data": {
    "disabled": false,
    "id": "78dd0b50-4147-4bb8-88d3-2ccc2e98bff0",
    "ingest_server": "rtmps://live.cloudflare.com:443/live/",
    "meeting_id": null,
    "name": "Livestreaming-Demo",
    "playback_url": "https://customer-s8oj0c1n5ek8ah1e.cloudflarestream.com/7de6a3fec0f9c05bf1df140950d3a237/manifest/video.m3u8",
    "status": "INVOKED",
    "stream_key": "f26566285faca6fbe2e79a73a66rsrrsrrsr3cde23a2bb7dbc6c2c1761b98f4e4"
  },
  "success": true
}