Programmable Media

Delete assets

Last updated: Jun-04-2024

There are a number of ways to delete assets from Cloudinary:

Programmatically:

  • Use the Destroy method of the Upload API to delete a single asset. This method requires a signature to be generated on the server side.
  • Use the Delete resources method of the Admin API to delete multiple assets. You can specify a set of assets to be deleted using delete_resources_by_prefix, delete_all_resources (optionally giving a type) or Delete resources by tag. These methods require your API key and secret, so are not suitable for use in client-side code.
  • Delete client-side uploaded assets using a delete token returned in the upload response that is valid for 10 minutes.

Via the Media Library:

When you delete assets, they are immediately and permanently removed from your cloud storage. However, assets and transformed assets already downloaded by visitors to your website, might still be accessible through cached copies on the CDN if they are not invalidated. From within the Media Library, an invalidate request is automatically included whenever you delete, rename, or overwrite media assets. If using the Destroy or Delete resources methods, you need to set the invalidate parameter to true to invalidate copies of the asset on the CDN. It usually takes between a few seconds and a few minutes for the invalidation to fully propagate through the CDN. There are also a number of other important considerations when using the invalidate functionality.

You can restore deleted assets from backup if you have enabled automatic backup for your product environment.

Delete assets video tutorial

Watch this video tutorial to learn more about deleting assets with a deep dive into the Node.js SDK methods.

Note
You can no longer access your full credentials directly from the Dashboard. Find your Cloud name on the Dashboard, and all credentials, including API Key, API Secret, and API environment variable, on the API Keys page of the Cloudinary Console Settings.

Delete one asset at a time

Jump to this spot in the video  1:17 To delete one asset at a time, you can use the destroy method of the upload API. Pass in the public ID of the asset to delete. If you don't pass in any other parameters, it is assumed that the asset is an image of delivery type 'upload'.

Delete an authenticated video

Jump to this spot in the video  2:06 If the asset you want to delete is not an image or of delivery type 'upload', you need to include the resource_type and/or type parameters. For example, to delete an authenticated video:

Invalidate the cache

Jump to this spot in the video  2:25 Even if you delete assets from your product environment they may still be accessible if they have been delivered and are cached on the CDN. To invalidate the cache, specify invalidate: true.

Delete multiple assets at a time

Jump to this spot in the video  2:52 To delete more than one asset at a time, use one of the delete resources methods of the admin API. Use the delete_resources method if you know the public IDs of the assets you want to delete.

Delete images by public ID prefix

Jump to this spot in the video  3:16 If all the assets you want to delete have public IDs that follow a convention (start with the same prefix), you can use the delete_resources_by_prefix method. For example, to delete all images of type 'upload' that have a public ID starting docs/:

Delete authenticated videos by public ID prefix

Jump to this spot in the video  3:38 To delete authenticated videos by public ID prefix, set the resource_type to video and type to authenticated as before:

Delete authenticated images by public ID prefix

Jump to this spot in the video  3:53 To delete authenticated images by public ID prefix, set the type to authenticated. There's no need to set resource_type to image as that's the default.

Delete all assets of a particular type

Jump to this spot in the video  4:10 Use the delete_all_resources method to delete all assets matching a particular asset type and delivery type. For example, to delete all Facebook images:

Delete all assets with the same tag

Jump to this spot in the video  4:35 Use the delete_resources_by_tag method to delete all assets that have the specified tag. By default, all images are deleted regardless of their delivery type. To delete videos, set the resource_type to video (as in the next example).

Delete only derived versions of assets

Jump to this spot in the video  5:09 You can delete only the derived versions of assets and keep the original intact, by setting the keep_original parameter to true.

Delete specific derived versions of assets

Jump to this spot in the video  5:35 The resource method returns details of derived versions of assets. You can use the IDs returned for each of the derived versions in the delete_derived_resources method to delete only those versions.