Documentation Index

Fetch the complete documentation index at: https://cloudinary.com/documentation/llms.txt

Use this file to discover all available pages before exploring further.

Image & Video APIs

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.

Delete UGC media PowerFlow on the canvas, branching into image, video, and raw paths that each email, delete, and log the asset

Tip
You can access MediaFlows from your Cloudinary Console. From there, create a new PowerFlow.

Sign up for free if you don't yet have a Cloudinary account.

Overview

The PowerFlow uses the following blocks:

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:

  1. Add the On Scheduled Search block to your canvas.
  2. Click the block to edit its settings.
  3. 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.
  4. 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-content applied, use the expression: created_at < 1d AND tags:ugc-content. Learn more about writing search expressions.
  5. Expand Advanced Options and set Maximum assets to process to the number of assets a run of the flow should process.

On Scheduled Search settings with an hourly schedule and a search expression

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 * * * ? *

Tip
Refer to the cron expression reference for more cron syntax.

Repeat For Each Asset

The Repeat For Each Asset block ensures that the subsequent blocks run for each asset returned by the search.

Steps:

  1. Add the Repeat For Each Asset block to your canvas and ensure it's connected to the On Scheduled Search block.
  2. Click the block to edit its settings.
  3. Set Source of asset list to On Scheduled Search > Resources (use the Insert Value icon to insert the variable).
  4. 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.

Repeat For Each Asset settings with Source of asset list set to On Scheduled Search Resources

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:

  1. Add the Branch On Condition block to your canvas and ensure it's connected to the Repeat For Each Asset block.
  2. Click the block to edit its settings.
  3. Set the name to something meaningful like Is It An Image.
  4. Set the Value type to String.
  5. In the Value field, click the Insert Value icon to insert a variable. Select Item > Resource type from Repeat For Each Asset.
  6. Set the Operator to is equal to.
  7. In the Compare to field, enter image.

Branch On Condition settings checking whether the resource type is equal to 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:

  1. 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.
  2. Click the block to edit its settings.
  3. Set the name to something meaningful like Is It A Video.
  4. Set the Value type to String.
  5. In the Value field, click the Insert Value icon to insert a variable. Select Item > Resource type from Repeat For Each Asset.
  6. Set the Operator to is equal to.
  7. In the Compare to field, enter video.

Branch On Condition settings checking whether the resource type is equal to 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:

  1. Add three Schedule Email Report blocks to the canvas.
  2. Ensure the first is connected to the Yes output of the Is It An Image block.
  3. Ensure the second is connected to the Yes output of the Is It A Video block.
  4. Ensure the third is connected to the No output of the Is It A Video block.
  5. Click each block in turn to edit its settings.
  6. Set the name to something meaningful like Schedule Image Email Report, Schedule Video Email Report, or Schedule Raw Email Report.
  7. Set Use the asset from to Repeat For Each Asset.
  8. Set the Recipients to one or more email addresses (separated by commas) that will receive the email.
  9. 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.
  10. Set the Report name to something meaningful to that branch, for example, Delete UGC Image.
  11. Set the Description to something meaningful to that branch, for example, Deleted UGC images.

Schedule Email Report settings for the image branch

The email that's sent looks something like this:

Scheduled email report

Delete Asset

The Delete Asset block deletes the specified asset from your Cloudinary product environment.

Steps:

  1. Add three Delete Asset blocks to the canvas.
  2. Ensure each is connected to the output of one of the Schedule Email Report blocks.
  3. Click each block in turn to edit its settings.
  4. Set the name to something meaningful like Delete Image, Delete Video, or Delete Raw.
  5. Set Use the asset from to Repeat For Each Asset.
  6. Turn on Invalidate to invalidate CDN cached copies of the asset.

Delete Asset settings using the asset from Repeat For Each Asset

Tip
If you have backups enabled on your product environment, consider also deleting backups.

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:

  1. Add three Add To Logs blocks to the canvas.
  2. Ensure each is connected to the output of one of the Delete Asset blocks.
  3. Click each block in turn to edit its settings.
  4. Set the name to something meaningful like Add To Logs Image, Add To Logs Video, or Add To Logs Raw.
  5. 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.

Add To Logs settings with a message that includes the public ID

✔️ Feedback sent!

Rate this page:

one star two stars three stars four stars five stars