Managing asset lifecycles
This guide provides step-by-step instructions on managing asset lifecycles in Prepr with support for custom transcoding or streaming services. Available exclusively to enterprise plan customers.
The asset lifecycle
The below stages make up the simple asset lifecycle.
Initial upload
The lifecycle begins when a user uploads a file via the Prepr UI, API, or FTP input. This triggers the asset.created
event, signaling the start of asset management.
File fully uploaded
When the file has been fully uploaded to Prepr's final storage location, the asset.uploaded
event is fired.
Integration hook
If integrating with another platform, listen for the asset.uploaded
event to begin file processing.
Integrating with external platforms
The steps below shows you how to handle key events when integrating with external platforms.
Creating a storage file in Prepr
After downloading the file to an external platform, you can register its location by creating a storage file.
You can use the following endpoint to create a storage file:
POST https://mutation.prepr.io/application/assets/{id}/storage_files
See an example payload below.
{
"url": "https://example.com/static.mp4",
"file": "static.mp4",
"extension": "mp4",
"downloadable": true,
"cdn": "custom_cdn"
}
Set the parameters as follows:
url
- The file's public URL.file
- The filename, including the extension.extension
- The file type (e.g., mp4).downloadable
- Indicates if the file is downloadable from the Prepr UI.cdn
- Name of the integration platform.
Requirement
Each platform must create at least one storage file.
Enabling public playback with CDN files
To enable public playback, create CDN files for each storage file:
You can use the following endpoint to enable public playback for each storage file.
POST https://mutation.prepr.io/application/storage_files/{id}/cdn_files
See an example payload below.
{
"file": "example.mp4",
"url": "https://examplecdn.com/example.mp4",
"profile": "mp4",
"cdn": "custom_cdn"
}
Set the parameters as follows:
file
- The filename.url
- The publicly accessible URL for playback.profile
- The format or type (e.g., mp4, hls).cdn
- This value must match the associated storage filecdn
.
This step can be repeated for multiple profiles (e.g., HLS, DASH). If the profile is set to hls
, it will be returned by the API by default when no profile is specified.
Finalizing the asset for online playback
After creating all the necessary CDN files, update the asset to indicate readiness for playback:
See an example payload below.
{
"reference_id": "custom_12345",
"duration": 60000,
"status": "Ready for playback",
"replaceable": false
}
Set the parameters as follows:
reference_id
- The unique internal asset identifier.duration
- The duration in milliseconds.status
- Provide a clear description for the readiness of the playback. For example,"Still processing"
.replaceable
- Determines if the file can be replaced via the UI.
Updates to https://mutation.prepr.io/assets/{id}
for CDN file information and status can also be performed while the file is being processed. Any status messages provided will be visible to Prepr users.
Handling file deletion events
To maintain synchronization with Prepr, listen for the following deletion events:
storage_file.deleted
- Trigger: This event is fired when a storage file is deleted, including cases where the entire asset is removed.
- Action: Delete any associated files if the
cdn
matches your integration's location.
cdn_file.deleted
- Trigger: This event is triggered when a CDN file is deleted.
- Action: Remove any related resources on your platform.
Listening for asset events with webhooks
To receive and process asset lifecycle events such as asset.uploaded
, storage_file.deleted
, and cdn_file.deleted
, create a webhook. Check out the Webhooks guide for more details.
Ensure your webhook endpoint can correctly handle and respond to incoming events.
Adding a cover thumbnail
You can use the standard mutation API post
endpoint to add a cover to your asset.
Check out the Manage assets doc for more details.
Was this article helpful?
We’d love to learn from your feedback