Delete temporary UGC assets
Last updated: Nov-05-2026
When you allow users to upload their own content to your product environment for time-bound activities, such as to see how your product looks in their environment, as in the Try before you buy use-case, you need to manage the deletion of these temporary assets.
One way to do this is to use MediaFlows to check periodically for uploaded assets that have been present for a certain amount of time and automatically delete them.
This guide demonstrates how to build a PowerFlow that does just that.
Sign up for free if you don't yet have a Cloudinary account.
Overview
The PowerFlow uses the following blocks:
- On Scheduled Search: Triggers the flow periodically and runs the rest of the flow for the assets returned by the search
- Repeat For Each Asset: Ensures that the subsequent blocks run for each asset returned by the search
- Branch On Condition: Checks if the asset is an image or video
- Schedule Email Report: Includes the asset from its part of the flow in a scheduled daily email
- Delete Asset: Deletes the asset from your Cloudinary product environment
- Add To Logs: Writes a message to the log
On Scheduled Search
The On Scheduled Search block triggers the flow periodically and runs the rest of the flow for the assets returned by the search.
Steps:
- Add the On Scheduled Search block to your canvas.
- Click the block to edit its settings.
- Set the Recurring schedule according to when you want the flow to trigger. Choose how often to Repeat the search (for example, Hourly, every 8 hours), or turn on Advanced to enter an AWS cron expression. See example cron expressions.
- Set Assets to search for to a search expression that returns the assets you want to delete. For example, to delete assets uploaded over a day ago with the tag
ugc-contentapplied, use the expression:created_at < 1d AND tags:ugc-content. Learn more about writing search expressions. - Expand Advanced Options and set Maximum assets to process to the number of assets a run of the flow should process.
Example cron expressions
| Scenario | AWS cron expression |
|---|---|
| Run every eight hours | 0 0/8 * * ? * |
| Run every day at 10:00 AM UTC | 0 10 * * ? * |
| Run every Monday at 2:00 PM UTC | 0 14 ? * MON * |
| Run once per hour | 0 * * * ? * |
Repeat For Each Asset
The Repeat For Each Asset block ensures that the subsequent blocks run for each asset returned by the search.
Steps:
- Add the Repeat For Each Asset block to your canvas and ensure it's connected to the On Scheduled Search block.
- Click the block to edit its settings.
- Set Source of asset list to On Scheduled Search > Resources (use the Insert Value icon to insert the variable).
- Turn on Run in parallel. The flow handles each asset independently of the others, so processing them all at once is faster than one at a time. Leave it off when the order matters, for example when each run depends on the result of the previous one.
Branch On Condition
There are two Branch On Condition blocks in this flow, which lead to three possible branches: one for images, one for videos, and one for raw files.
Is it an image?
The first Branch On Condition block checks if the asset is an image. If it isn't, the flow moves to the second Branch On Condition block, which checks if it's a video.
Steps:
- Add the Branch On Condition block to your canvas and ensure it's connected to the Repeat For Each Asset block.
- Click the block to edit its settings.
- Set the name to something meaningful like
Is It An Image. - Set the Value type to
String. - In the Value field, click the Insert Value icon to insert a variable. Select Item > Resource type from Repeat For Each Asset.
- Set the Operator to is equal to.
- In the Compare to field, enter
image.
The flow follows the Yes output if the condition is true (in this case if the resource type is "image"), otherwise it continues through the No output.
Is it a video?
If the asset isn't an image, the flow moves on to check if it's a video.
Steps:
- Add the Branch On Condition block to your canvas and ensure it's connected to the No output of the Is It An Image block.
- Click the block to edit its settings.
- Set the name to something meaningful like
Is It A Video. - Set the Value type to
String. - In the Value field, click the Insert Value icon to insert a variable. Select Item > Resource type from Repeat For Each Asset.
- Set the Operator to is equal to.
- In the Compare to field, enter
video.
If the asset isn't an image or video, the flow presumes that it's a raw file.
Schedule Email Report
At this point in the flow there are three branches. Add the next three blocks to each of the branches and configure them according to whether the asset is an image, video, or raw file.
The Schedule Email Report block includes the asset from its branch of the flow in a scheduled daily email.
Steps:
- Add three Schedule Email Report blocks to the canvas.
- Ensure the first is connected to the Yes output of the Is It An Image block.
- Ensure the second is connected to the Yes output of the Is It A Video block.
- Ensure the third is connected to the No output of the Is It A Video block.
- Click each block in turn to edit its settings.
- Set the name to something meaningful like
Schedule Image Email Report,Schedule Video Email Report, orSchedule Raw Email Report. - Set Use the asset from to Repeat For Each Asset.
- Set the Recipients to one or more email addresses (separated by commas) that will receive the email.
- Set the Time to the UTC time at which the email will be sent. If the flow runs three times a day, and this block fires in one or more of those runs, the flow sends one email per day.
- Set the Report name to something meaningful to that branch, for example,
Delete UGC Image. - Set the Description to something meaningful to that branch, for example,
Deleted UGC images.
The email that's sent looks something like this:
Delete Asset
The Delete Asset block deletes the specified asset from your Cloudinary product environment.
Steps:
- Add three Delete Asset blocks to the canvas.
- Ensure each is connected to the output of one of the Schedule Email Report blocks.
- Click each block in turn to edit its settings.
- Set the name to something meaningful like
Delete Image,Delete Video, orDelete Raw. - Set Use the asset from to Repeat For Each Asset.
- Turn on Invalidate to invalidate CDN cached copies of the asset.
Add To Logs
The Add To Logs block writes whatever message you want to the log. In this case, you could record the asset's public ID.
Steps:
- Add three Add To Logs blocks to the canvas.
- Ensure each is connected to the output of one of the Delete Asset blocks.
- Click each block in turn to edit its settings.
- Set the name to something meaningful like
Add To Logs Image,Add To Logs Video, orAdd To Logs Raw. - Set the Message to something meaningful. To add the public ID of the deleted asset, click the Insert Value icon to insert the Repeat For Each Asset > Item > Public ID variable.








