Managing video lifecycles with scheduled deletion

Cloudflare Stream is adding scheduled deletion to help developers control how long on-demand videos and live stream recordings remain in storage. Announced on August 11, 2023, the feature is available through the Stream dashboard and API, letting teams set automatic removal times to reduce storage overhead and manage content lifecycles without manual cleanup.

The feature works for two use cases: individual videos (including direct creator uploads and recordings from finished live streams) and live input configurations. For live inputs, an admin can define a retention rule so that every future recording from that input gets a deletion date calculated automatically when the stream ends.

Scheduled deletion for on-demand videos

On-demand videos — whether uploaded by students on a learning platform, gamers sharing clips, or any other creator content — can be assigned a specific deletion date and time. The setting applies to new uploads, existing videos, and recordings from completed live streams. Configuration is available in both the Cloudflare dashboard and via the Stream API.

Setting a deletion date from the dashboard

BLOG-1985 Embedded Image - VZaeQ1
  1. From the Cloudflare dashboard, select Videos under Stream
  2. Select a video
  3. Select Automatically Delete Video
  4. Specify a desired date and time to delete the video
  5. Click Submit to save the changes

Configuring deletion via the API

The Stream API lets you set the scheduled deletion property when creating or updating videos. For example, the following request creates a direct creator upload with a deletion date of December 31, 2023:

curl -X POST \
-H 'Authorization: Bearer <BEARER_TOKEN>' \
-d '{ "maxDurationSeconds": 10, "scheduledDeletion": "2023-12-31T12:34:56Z" }' \
https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/stream/direct_upload 

Retention policies for live input recordings

Live stream recordings are useful for viewers who missed the broadcast, but they are often not needed indefinitely. Scheduled recording deletion is a policy you can attach to a new or existing live input. Once set, every future stream recording on that input is given a deletion date when the recording becomes available. You can configure this policy from the dashboard or through API calls that create or edit live inputs.

Configuring retention from the dashboard

BLOG-1985 Embedded Image - uwpZkr
  1. From the Cloudflare dashboard, select Live Inputs under Stream
  2. Select Create Live Input or an existing live input
  3. Select Automatically Delete Recordings
  4. Specify a number of days after which new recordings should be deleted
  5. Click Submit to save the rule or create the new live input

Adding a deletion policy with the API

The Stream API supports adding a deletion policy to new or existing inputs. Here is an example request that creates a live input whose recordings expire after 30 days:

curl -X POST \
-H 'Authorization: Bearer <BEARER_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{ "recording": {"mode": "automatic"}, "deleteRecordingAfterDays": 30 }' \
https://api.staging.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/stream/live_inputs/

For more details on live inputs and configuring deletion policies via the API, refer to the documentation.

Scheduled deletion is now available to all Cloudflare Stream customers. For further guidance, check the developer docs or join the Discord community to share feedback.