# Broadcast automation

This guide walks through running scheduled pre-recorded (PRL) broadcasts end to end without
opening the dashboard: upload a master recording once, schedule it as several broadcasts a
day, point each broadcast at its own platform event, end or remove broadcasts, and keep the
Livepush web player private.

It assumes you already have a stream with category `schedule`. If not, start with
[Pre-recorded streams](/guides/pre-recorded-streams/).

## Before you start

**API access is on every plan, including Free.** The dashboard is built on these same
endpoints, so anything you can do in the dashboard you can do through the API. Your plan
limits (below) apply the same way to both.

**Watch the dashboard to see the exact request.** If you are unsure what a step sends, open
your browser's developer tools, switch to the **Network** tab and perform the step in the
dashboard. The request URL, method and JSON payload shown there are exactly what your code
should send.

**Support scope.** Dedicated developer assistance is included from the Business plan
(social streaming) and the Studio plan (live hosting) upward. On other plans this guide and
the endpoint reference are the support material, so each step below includes a full request
and response.

## Plan limits that shape your automation

| | Free | Pro | Creators | Business |
| --- | --- | --- | --- | --- |
| Pre-recorded streams live or scheduled at once | 1 | 2 | 3 | 12 |
| Events in the schedule queue, per stream | 1 | 8 | 16 | 80 |
| Longest playback per event | 30 min | 4 h | No limit | No limit |
| Looping and 24/7 channels | No | No | Yes | Yes |
| Custom RTMP destinations | No | Yes | Yes | Yes |
| Player password and geo-blocking | No | No | Yes | Yes |

Two of these are counted in ways that matter for automation:

- **The queue limit counts every unfinished event on the stream**, upcoming and running.
  Finished events do not count. If your daily schedule has more broadcasts than your queue
  allows, keep a rolling window: create the next event each time one finishes, rather than
  queueing the whole day up front.
- **The "at once" limit counts streams, not events.** A stream takes a slot as soon as it
  holds an upcoming or running event, even while it is idle and waiting. Nine back-to-back
  broadcasts on **one** stream use one slot. The same nine spread over nine streams use
  nine. Disabling a stream frees its slot.

## 1. Scopes

Issue a token through the [OAuth flow](/guides/authentication/) with only the scopes the
automation needs:

| Scope | Used for |
| --- | --- |
| `streams.read` | Reading streams, listing and reading scheduled events |
| `streams.write` | Creating, updating, ending and deleting events, event playlists, all web player (embed) settings |
| `streams.destinations.write` | Creating, updating, enabling and disabling destinations |
| `streams.videos.read` | Listing videos, signed thumbnail and download URLs, storage specs |
| `streams.videos.write` | Upload URLs and upload sessions, registering a video, reading, updating and deleting a video, codec info, re-transcoding |

Every request below sends `Authorization: Bearer YOUR_API_TOKEN` and goes to
`https://octopus.livepush.io`. `st_xxxxxxxxxxxxx` stands for your stream id.

## 2. Upload the master video

Upload the recording once, then schedule it as many times as you like. Uploading takes
five calls: find the storage zone, create an upload URL, open a session on the upload
middleware, send the file to it, and register the video. The
[Uploading videos](/guides/uploading-videos/) guide walks through each call with full
requests and responses, and ends with a script that does all five.

Keep the video `id` returned by the register call. That is the id you schedule with.

## 3. Wait until the video is ready

[Get video by ID](/videos/get-video-by-id/)

```bash
curl -X GET 'https://octopus.livepush.io/streams/me/videos/Xk2fP9qLm' \
  -H 'Authorization: Bearer YOUR_API_TOKEN'
```

```json
{
  "id": "Xk2fP9qLm",
  "label": "Morning session (master)",
  "encodable": true,
  "encoded": true,
  "encodedAt": "2026-12-02T08:21:44.000Z",
  "encoderLog": { "percent": 97.83 },
  "mediaInfo": { "duration": 3540000, "width": 1920, "height": 1080, "tracks": ["…"] }
}
```

**A video is ready to schedule when `encoded` is `true` and `encodedAt` is set.** Poll every
30 to 60 seconds until both hold.

- **Do not gate on `encoderLog.percent`.** It is the last progress value the encoder
  reported and often stops short of 100 (97.83 in the example above) on a video that is
  finished. It can also be missing
  entirely, including on videos that encoded fine.
- **Check `encodable` on the first poll.** If it is `false`, the video was not queued for
  encoding and `encoded` will never turn `true`, so stop polling and surface the problem
  instead of waiting forever.

Wait for readiness before step 4 for a second reason: the scheduler works out each event's
length, conflicts and plan limits from the video's duration, which is filled in by
processing.

## 4. Schedule the broadcasts

### 4.1 You do not need to set the scheduler mode

Creating an event switches the stream into events mode by itself, so skip
[Set scheduler mode](/stream-scheduler/set-scheduler-mode/).

> **Warning.** `PUT .../config/scheduler/mode` replaces the stream's whole scheduler
> configuration with just the mode. Calling it on a stream that already has a playlist,
> looping or queued events clears all of them, including upcoming broadcasts. If you
> must call it, do it once on a new stream, before creating any event, with
> `{"mode": "events"}`.

### 4.2 Create one event per broadcast

[Schedule a pre-recorded live stream](/stream-scheduler/schedule-a-pre-recorded-live-stream/)

```bash
curl -X POST 'https://octopus.livepush.io/streams/st_xxxxxxxxxxxxx/config/scheduler/events' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "label": "Morning session 09:00",
    "datetime": "2026-12-03T04:00:00.000Z",
    "videos": ["Xk2fP9qLm"],
    "repeatCount": 1
  }'
```

```json
{
  "id": "ev_xxxxxxxxx",
  "label": "Morning session 09:00",
  "datetime": "2026-12-03T04:00:00.000Z",
  "datetimeEnd": "2026-12-03T04:59:00.000Z",
  "runtime": 3540000,
  "videos": ["Xk2fP9qLm"],
  "repeatCount": 1,
  "awaiting": true,
  "isActive": false,
  "stream": "st_xxxxxxxxxxxxx"
}
```

Store the returned `id`. Every later call about this broadcast uses it.

| Field | Meaning |
| --- | --- |
| `label` | Required. Shown in the dashboard. |
| `datetime` | Required. Start time, ISO 8601 in UTC. |
| `videos` | Video ids to play, in order. **Always send this** (see below). |
| `repeatCount` | How many times the playlist plays. `0` or `1` plays it once. |
| `datetimeEnd` | Optional hard end time. When set without `repeatCount`, the event runs until this time. |
| `loop` | Repeat until ended. Creators and above only. |
| `immediateStart` | Start about 20 seconds from now instead of at `datetime`. |
| `preciseStart` | Ask for an exact start time; normally set by the scheduler itself. |

Things to know when creating events in bulk:

- **Always send `videos`.** Without it the event's length is estimated from every video in
  your library, which can push a short broadcast over your plan's per-event runtime limit
  and get it rejected. Every id must be a video in your library; an unknown id currently
  fails with a `500` rather than a clear error.
- **Events on one stream cannot overlap.** The scheduler computes each event's end from its
  videos and `repeatCount` (or `datetimeEnd`) and rejects a start that falls inside another
  event's window. Leave a gap of a few minutes between broadcasts so a destination swap
  (section 5) has time to apply.
- **Immediate or looping starts on some storage zones are pushed back.** When the video sits
  in a preloading zone, the start is moved to at least 66 seconds from now, plus 7 seconds
  per GB of the first video, so the file can be staged. Read `datetime` back from the
  response rather than assuming it.

### 4.3 Errors to handle

Failures come back with a machine-readable `error` code. Branch on the code, not on the
message text or the status. Plan limits return `405`, except
`max_active_streams_quota_reached`, which returns `403`; a time conflict returns `400`.
An unknown stream id currently returns `502`. The [Errors](/guides/errors/) guide has the
full list.

| `error` | Cause | What to do |
| --- | --- | --- |
| `schedule_time_conflict` | Overlaps another event on the same stream. `data.schedule` names it. | Move the start, or end or delete the other event. |
| `max_events_quota_reached` | The stream already holds as many unfinished events as your plan's queue allows (also returned for a disabled stream). | Wait for an event to finish, or delete an upcoming one. |
| `max_active_streams_quota_reached` | Your plan's "at once" limit is used by other streams with upcoming or running events. `data` has `limit` and `committed`. | Let events finish, delete upcoming ones, or schedule on a stream that is already committed. |
| `max_runtime_per_event_reached` | The event is longer than your plan allows, or `loop` was requested without looping on the plan. | Shorten the playlist or `repeatCount`, or upgrade. |
| `max_repeat_per_event_reached` | `repeatCount` is above the plan limit. | Lower it. |
| `subscription_not_found` | The account has no active pre-recorded plan. | Subscribe to a pre-recorded plan. |

### 4.4 Change a scheduled event

To move or rename an upcoming event,
[Update scheduled event](/stream-scheduler/update-scheduled-event/):

```bash
curl -X PUT 'https://octopus.livepush.io/streams/st_xxxxxxxxxxxxx/config/scheduler/events/ev_xxxxxxxxx' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "label": "Morning session 09:30",
    "datetime": "2026-12-03T04:30:00.000Z",
    "repeatCount": 1
  }'
```

The response is the updated event. Only the fields you send are changed, with one
exception: **always resend `repeatCount`**. An update that leaves it out resets it to `0`.

To change only which videos an event plays,
[Set event videos](/stream-scheduler/set-event-videos/):

```bash
curl -X PUT 'https://octopus.livepush.io/streams/st_xxxxxxxxxxxxx/config/scheduler/ev_xxxxxxxxx/playlist' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"videos": ["Xk2fP9qLm"]}'
```

```json
{ "success": true }
```

Note the path: there is no `/events/` segment in this one. The list replaces the event's
playlist; it is not appended to. This call also sets the stream's default playlist to the
same list.

### 4.5 List and check events

[List scheduled events](/stream-scheduler/list-scheduled-events/)

```bash
curl -X GET 'https://octopus.livepush.io/streams/st_xxxxxxxxxxxxx/config/scheduler/events?limit=50' \
  -H 'Authorization: Bearer YOUR_API_TOKEN'
```

```json
{
  "events": [
    {
      "id": "ev_xxxxxxxxx",
      "label": "Morning session 09:00",
      "datetime": "2026-12-03T04:00:00.000Z",
      "datetimeEnd": "2026-12-03T04:59:00.000Z",
      "awaiting": true,
      "isActive": false,
      "isArchived": false
    }
  ],
  "hasMore": true,
  "nextCursor": { "before": "2026-12-03T04:00:00.000Z", "beforeId": "ev_xxxxxxxxx" }
}
```

The list includes upcoming, running and finished events, newest first. `limit` defaults to
50 and is capped at 200. For the next page, pass `nextCursor.before` and
`nextCursor.beforeId` back as the `before` and `beforeId` query parameters; `nextCursor` is
`null` on the last page.

One event by id, [Get scheduled event](/stream-scheduler/get-scheduled-event/):

```bash
curl -X GET 'https://octopus.livepush.io/streams/st_xxxxxxxxxxxxx/config/scheduler/events/ev_xxxxxxxxx' \
  -H 'Authorization: Bearer YOUR_API_TOKEN'
```

Read an event's state from its flags:

| State | Flags |
| --- | --- |
| Upcoming | `awaiting: true` |
| On air | `isActive: true` |
| Finished | `isArchived: true` |

## 5. A separate platform event per broadcast

When each broadcast needs its own YouTube live event, create the YouTube side with the
YouTube Data API, then point the Livepush stream at that event's ingest shortly before the
broadcast starts.

On YouTube, each live event (a `liveBroadcast` bound to a `liveStream`) gives you an ingest
address and stream name in `liveStream.cdn.ingestionInfo`. Those become the RTMP URL and key
below. Whether the broadcast and its replay are public, unlisted or private is set there
too, through the YouTube API's privacy status; Livepush does not control it.

### Recommended: one custom RTMP destination, re-pointed per broadcast

Create a single custom RTMP destination once:

[Create new stream destination](/destinations/create-new-stream-destination/)

```bash
curl -X POST 'https://octopus.livepush.io/streams/st_xxxxxxxxxxxxx/destinations' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "appName": "rtmp",
    "label": "YouTube (per-broadcast)",
    "rtmpBase": "rtmp://a.rtmp.youtube.com/live2",
    "rtmpKey": "FIRST_EVENT_STREAM_NAME",
    "isDisabled": false
  }'
```

```json
{
  "id": "pb_xxxxxxxxxxxx",
  "appName": "rtmp",
  "label": "YouTube (per-broadcast)",
  "rtmpBase": "rtmp://a.rtmp.youtube.com/live2",
  "isDisabled": false
}
```

New destinations are created **disabled** unless you send `"isDisabled": false`.

Then, a few minutes before each broadcast, swap in that broadcast's ingest with
[Update destination RTMP ingest](/destinations/update-destination-rtmp-ingest/):

```bash
curl -X PUT 'https://octopus.livepush.io/streams/st_xxxxxxxxxxxxx/destinations/pb_xxxxxxxxxxxx/rtmp' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "rtmpBase": "rtmp://a.rtmp.youtube.com/live2",
    "rtmpKey": "NEXT_EVENT_STREAM_NAME"
  }'
```

```json
{ "success": true }
```

This keeps the stream at one destination however many broadcasts you run, so you never
reach your plan's destination limit. Only swap after the previous broadcast has ended: a
swap during a running broadcast moves that broadcast to the new key.

### Alternative: one destination per broadcast

You can also create a new custom RTMP destination for each broadcast, then use
[Enable stream destination](/destinations/enable-stream-destination/) on it and
[Disable stream destination](/destinations/disable-stream-destination/) on the previous
one:

```bash
curl -X PUT 'https://octopus.livepush.io/streams/st_xxxxxxxxxxxxx/destinations/pb_next/enable' \
  -H 'Authorization: Bearer YOUR_API_TOKEN'

curl -X PUT 'https://octopus.livepush.io/streams/st_xxxxxxxxxxxxx/destinations/pb_previous/disable' \
  -H 'Authorization: Bearer YOUR_API_TOKEN'
```

Both return `{ "success": true }`. Delete destinations you no longer need with
[Delete stream destination](/destinations/delete-stream-destination/), otherwise they
accumulate and count against your plan's destination limits.

## 6. End or remove a broadcast

**End a broadcast that is on air:**
[End active scheduled stream](/stream-scheduler/end-active-scheduled-stream/)

```bash
curl -X PUT 'https://octopus.livepush.io/streams/st_xxxxxxxxxxxxx/config/scheduler/events/ev_xxxxxxxxx/end' \
  -H 'Authorization: Bearer YOUR_API_TOKEN'
```

```json
{ "success": true }
```

The call is accepted immediately; playback and destination disconnects take a few seconds
after that. Confirm with the event (`isArchived: true`) or the heartbeat in section 8
rather than assuming the broadcast is down when the call returns. A broadcast that reaches
the end of its playlist ends by itself; you only need this call to stop one early.

**Remove a broadcast:**
[Delete scheduled stream event](/stream-scheduler/delete-scheduled-stream-event/)

```bash
curl -X DELETE 'https://octopus.livepush.io/streams/st_xxxxxxxxxxxxx/config/scheduler/events/ev_xxxxxxxxx' \
  -H 'Authorization: Bearer YOUR_API_TOKEN'
```

```json
{ "success": true }
```

Use this to cancel an upcoming broadcast or to clear a finished one from the history. It
leaves the stream, its destinations and its videos untouched, with one exception: on a
one-off (disposable) event stream, deleting the event deletes the stream with it.

## 7. Keep the Livepush web player private

Every stream has a Livepush web player, and it is on by default. If your audience should
only watch on YouTube, restrict the player. All four calls need `streams.write` and each
returns `{ "success": true }`.

**Allow only your own domains**
([Set allowed embed domains](/stream-embed/set-allowed-embed-domains/)). The body is a
plain array; an empty array allows every domain again.

```bash
curl -X PUT 'https://octopus.livepush.io/streams/st_xxxxxxxxxxxxx/embed/domains' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '["app.example.com"]'
```

**Control iframe hosting**
([Set iframe hosting rule](/stream-embed/set-iframe-hosting-rule/)). `iframe-only` stops
the player page being opened directly; `no-iframe` stops it being embedded.

```bash
curl -X PUT 'https://octopus.livepush.io/streams/st_xxxxxxxxxxxxx/embed/iframe_restriction' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"iframeRestriction": "iframe-only"}'
```

**Require a password**
([Set embed password](/stream-embed/set-embed-password/)). Creators and above. Send an
empty string to remove it.

```bash
curl -X PUT 'https://octopus.livepush.io/streams/st_xxxxxxxxxxxxx/embed/password' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"password": "a-long-random-string"}'
```

**Limit by country**
([Set embed geo restrictions](/stream-embed/set-embed-geo-restrictions/)). Creators and
above. ISO country codes; an empty array allows every country.

```bash
curl -X PUT 'https://octopus.livepush.io/streams/st_xxxxxxxxxxxxx/embed/geo' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '["US", "GB"]'
```

These settings apply to the stream, so set them once rather than per broadcast. They have
no effect on YouTube: visibility of the broadcast and its replay there is controlled on the
YouTube side.

## 8. Monitor a broadcast

The public heartbeat reports whether a stream is on air. It needs no token; pass the
stream's `streamKey` (returned by [Get stream by ID](/streams/get-stream-by-id/)).

```bash
curl 'https://state.livepush.io/streams/heartbeat?streamKey=YOUR_STREAM_KEY'
```

When the stream is not on air:

```json
{ "isLive": false, "active": false }
```

While it is on air, `active` is `true` and the response also carries the outgoing bitrate,
frame rate and resolution. Poll it once a minute or so around each broadcast's start time
to confirm the broadcast actually went out, and after an end call to confirm it stopped.

## Putting it together

A daily run for several broadcasts from one master recording, on one stream:

1. **Once:** upload the master (section 2), wait for `encoded` (section 3), create the
   custom RTMP destination (section 5) and restrict the web player (section 7).
2. **For each broadcast:** create the YouTube live event, then create the Livepush event
   with `videos` set to the master and `repeatCount: 1` (section 4.2). If the day has more
   broadcasts than your queue allows, create each one as the previous finishes.
3. **A few minutes before each start:** swap the destination to that broadcast's ingest
   (section 5).
4. **Around each start:** confirm it is on air with the heartbeat (section 8).
5. **If you need to stop early:** end the event (section 6). Otherwise it ends when the
   video does.
