> ## 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.

# Delete assets


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

**Programmatically:**

* Use the [Destroy](image_upload_api_reference#destroy_method) 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](admin_api#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](admin_api#delete_resources_by_tags).  These methods require your API key and secret, so are not suitable for use in client-side code.
* [Delete client-side uploaded assets](client_side_uploading#deleting_client_side_uploaded_assets) using a delete token returned in the upload response that is valid for 10 minutes. 

**Via the Media Library:**

* [Select and delete assets](media_library_for_developers#deleting_assets) in the Media Library.
* [Delete folders](dam_folders_collections_sharing#delete_folders) and their contents in the Media Library.

**In bulk, via Console Settings:**

You can bulk delete several assets at a time using set criteria from your [Console Settings](https://console.cloudinary.com/app/settings/settings/bulk_delete/new).

1. In **Settings > Bulk Delete**, choose whether to delete **originals and derived resources** or **derived only**.
1. Under **Search by**, select the criteria by which you want to select the assets to delete.
1. Select the relevant **Resource type** (image, video, raw, any, all) and **Type** (upload, private, authenticated, list, etc) of the assets to delete.
1. If automatic backups are enabled for your product environment, optionally select **Clear backed‑up versions** for the affected assets.
1. Click **Next**, confirm with your account password, and submit the job. You'll receive an email notification when the process completes.

> **NOTES**:
>
> * Under **Resource type**, **Any** is relevant only for [client-side list (JSON) assets](list_assets#client_side_asset_lists) where `any` was the passed resource_type when generating the list. Whereas **All** represents all resource types.

> * The options available under the **Type** options depend on the **Resource type** selected, and is not relevant when **Tag** is selected for the **Search by** option.

For information about backed‑up versions and restoration options, see [Backups and version management](backups_and_version_management#banner).

## Understanding asset deletion

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](image_upload_api_reference#destroy_method) or [Delete resources](admin_api#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](invalidate_cached_media_assets_on_the_cdn) when using the invalidate functionality.

You can [restore deleted assets](backups_and_version_management#restoring_deleted_assets_from_backup) from backup if you have [enabled automatic backup](backups_and_version_management#enabling_automatic_backup) for your product environment.
> **INFO**: The default resource type for most API requests is `image`. When working with videos, remember to explicitly set the `resource_type` to `video`.

## Delete assets video tutorial

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

  This video is brought to you by Cloudinary's video player - embed your own!Use the controls to set the playback speed, navigate to chapters of interest and select subtitles in your preferred language.

### Tutorial contents This tutorial presents the following topics. Click a timestamp to jump to that part of the video.

{table:class=tutorial-bullets}|  |  
| --- | --- |
|{videotime:id=media :min=0 :sec=00 :player=cld} | There are many ways to delete assets from Cloudinary.  In the [Cloudinary Console](https://console.cloudinary.com/console), you can delete individual or multiple assets from your [Media Library](https://console.cloudinary.com/console/media_library/search), or, in the Settings, you can bulk delete many assets based on various criteria.

#### Delete assets using the Node.js SDK
{table:class=tutorial-bullets}|  |  
| --- | --- |
|{videotime:id=media :min=0 :sec=56 :player=cld} | As deleting assets is a backend operation, you need to set your Cloudinary API environment variable, which you can copy from the **Dashboard** page in the [Cloudinary Console](https://console.cloudinary.com/console). Paste it into a **.env** file, but don't submit this to version control as it contains your API secret, which should never be exposed.|
> **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](https://console.cloudinary.com/app/settings/api-keys) page of the Cloudinary Console Settings.
#### Delete one asset at a time
{table:class=tutorial-bullets}|  |  
| --- | --- |
|{videotime:id=media :min=1 :sec=17 :player=cld} | To delete one asset at a time, you can use the [destroy method of the upload API](image_upload_api_reference#destroy). 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](image_transformations#delivery_types) 'upload'.|

```nodejs
cloudinary.uploader
  .destroy('docs/vegetables')
  .then(result => console.log(result));
```

#### Delete an authenticated video
{table:class=tutorial-bullets}|  |  
| --- | --- |
|{videotime:id=media :min=2 :sec=06 :player=cld} | 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:|

```nodejs
cloudinary.uploader
    .destroy('docs/stream', {resource_type: 'video', type: 'authenticated'})
    .then(result => console.log(result));
```

#### Invalidate the cache
{table:class=tutorial-bullets}|  |  
| --- | --- |
|{videotime:id=media :min=2 :sec=25 :player=cld} | 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`.|

```nodejs
cloudinary.uploader
    .destroy('docs/lemonade', {resource_type: 'video', invalidate: true, type: 'authenticated'})
    .then(result => console.log(result));
```

#### Delete multiple assets at a time
{table:class=tutorial-bullets}|  |  
| --- | --- |
|{videotime:id=media :min=2 :sec=52 :player=cld} | To delete more than one asset at a time, use one of the [delete resources methods of the admin API](admin_api#delete_resources). Use the `delete_resources` method if you know the public IDs of the assets you want to delete.|

```nodejs
cloudinary.api
    .delete_resources(['docs/strawberries', 'docs/owl'])
    .then(result=>console.log(result));
```

#### Delete images by public ID prefix
{table:class=tutorial-bullets}|  |  
| --- | --- |
|{videotime:id=media :min=3 :sec=16 :player=cld} | 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/`:|

```nodejs
cloudinary.api
    .delete_resources_by_prefix('docs/')
    .then(result=>console.log(result));
```

#### Delete authenticated videos by public ID prefix
{table:class=tutorial-bullets}|  |  
| --- | --- |
|{videotime:id=media :min=3 :sec=38 :player=cld} | To delete authenticated videos by public ID prefix, set the `resource_type` to `video` and `type` to `authenticated` as [before](#delete_an_authenticated_video): |

```nodejs
cloudinary.api
    .delete_resources_by_prefix('docs/', {resource_type: 'video', type: 'authenticated'})
    .then(result=>console.log(result)); 
```

#### Delete authenticated images by public ID prefix
{table:class=tutorial-bullets}|  |  
| --- | --- |
|{videotime:id=media :min=3 :sec=53 :player=cld} | 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.|

```nodejs
cloudinary.api
    .delete_resources_by_prefix('docs/', {type: 'authenticated'})
    .then(result=>console.log(result)); 
```

#### Delete all assets of a particular type
{table:class=tutorial-bullets}|  |  
| --- | --- |
|{videotime:id=media :min=4 :sec=10 :player=cld} | Use the `delete_all_resources` method to delete all assets matching a particular [asset type](upload_parameters#asset_types) and [delivery type](image_transformations#delivery_types). For example, to delete all Facebook images: |

```nodejs
cloudinary.api
    .delete_all_resources({type: 'facebook'})
    .then(result=>console.log(result)); 
```

#### Delete all assets with the same tag
{table:class=tutorial-bullets}|  |  
| --- | --- |
|{videotime:id=media :min=4 :sec=35 :player=cld} | 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)).|

```nodejs
cloudinary.api
    .delete_resources_by_tag('mine')
    .then(result=>console.log(result));
```

#### Delete only derived versions of assets
{table:class=tutorial-bullets}|  |  
| --- | --- |
|{videotime:id=media :min=5 :sec=09 :player=cld} | You can delete only the derived versions of assets and keep the original intact, by setting the `keep_original` parameter to true. |

```nodejs
cloudinary.api
    .delete_resources_by_tag('mine', {resource_type: 'video', keep_original: true})
    .then(result=>console.log(result));
```

#### Delete specific derived versions of assets
{table:class=tutorial-bullets}|  |  
| --- | --- |
|{videotime:id=media :min=5 :sec=35 :player=cld} | The [resource](admin_api#get_details_of_a_single_resource_by_public_id) 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.|

```nodejs
cloudinary.api
    .resource('docs/stream', {resource_type: 'video'})
    .then(result=>console.log(result));

cloudinary.api
    .delete_derived_resources(['76b6ee3a81e20e110ab81d368d18ff53', '349bfe6c9813708c5398f5cadf391a7d'])
    .then(result=>console.log(result));
```

