Delete a single asset
Deleting a single asset can be done using the destroy
method of our Upload API, and our client SDKs provide methods to call this API from your application code.
For example, using our Node JS SDK, a simple call to delete an image asset called 'zombie' is:
cloudinary.uploader.destroy('zombie', function(result) { console.log(result) });
You can try this below using your own account details
For more information about this API method, please see the documentation:
https://cloudinary.com/documentation/image_upload_api_reference#destroy_method
Delete multiple assets
Bulk deletions using various criteria can be performed via the Admin API or by using the bulk delete from the Media Library UI in the management console.
Using the Admin API, you can delete up to 100 specific public_id values in a single API call or up to 1000 assets when deleting all assets sharing a prefix, tax, etc.
The Admin API is rate limited, so the best practice is to use the Upload API when deleting a small number of specific assets, and to use the Admin API for infrequent bulk operations such as storage cleanups or removing assets related to products or features that are no longer required.
Bulk delete UI
Using the bulk delete feature in the management console, it's also possible to execute bulk deletion jobs based on many different characteristics like upload date, tag, prefix, resource type, etc. The bulk deletion interface can be found in the account settings page of accounts with a Media Library (e.g. DAM and Programmable Media accounts) - after you create a job and share the details, a process runs in the background to remove the specified assets.
For example, to delete all assets created between 2020-06-28 and 2020-08-02, you can create a job using the following options:
Comments
13 comments
For those interested in the Admin API usage limits. http://cloudinary.com/documentation/admin_api#protocol_and_authentication > Usage Limits.
I am trying to delete with REST API (https://cloudinary.com/documentation/image_upload_api_reference#destroy)
But I am getting Error
```
{
"error": {
"message": "Invalid Signature 2cfb6ad66a0c6f00713f58e2eafaecfdd92XXXXX. String to sign - 'public_id=hf23hjp7swkslsih3dfd×tamp=1502454673000'."
}
}
```
Hi Chetan,
Can you please open a support ticket here-https://support.cloudinary.com/hc/en-us/requests/new with your account details and the URL of the resource you are trying to delete and we will be able to reproduce the issue.
Also, you can check our signature generation doc here for more details-https://cloudinary.com/documentation/upload_images#generating_authentication_signatures
The example code is missing the err parameter to the callback before result. This code will log the error, not the result. Should be:
What is zombie? How you insert the file you want to delete? Do you put in the full URL? the Path ???
Hi Berry, 'zombie' is the public_id (i.e., its name) of the image.
Here's a link to the docs:
https://cloudinary.com/documentation/image_upload_api_reference#destroy_method
its possible delete it without callback?how?
Hi Osmel,
The callback is needed only in NodeJS because it's asynchronous. In the callback, you would access the response received for the API call you performed. Other Cloudinary SDKs, such as Ruby, PHP or Python don't use callbacks as they are not relevant for those languages.
Are you currently using NodeJS in your application? Could you share more details as to why you cannot use callbacks or what issue you are encountering?
Hi aleksandar, I did it using a callback and it works perfectly, with your explanation it is now clear to me, thanks for the help
Unfortunately the bulk delete interface does nothing....
0 resources were deleted ( 0 original and 0 derived ).
Hi Cristian,
This article was referring to the Programmable Media Product which was before Media Optimizer (which is the account type you have). With Media Optimizer there is no Storage component of assets on Cloudinary as the images are only cached on Cloudinary but not strictly stored there as with Programmable Media. Therefore, accessing and running a Bulk Delete for a Media Optimizer account has no effect and the output you received is expected. I have updated the Knowledge Base so that it explicitly mentions that this is relating to the Programmable Media product to avoid confusion in future. I also see that you raise a ticket directly with us regarding this topic so I've also replied there.
ummm ok...and how on earth can i tell cloudinary to fetch the data (images/video/whatever again) without going through all urls manualy ?
[root@frinks ~]# curl https://xxxx:xxxx@api-eu.cloudinary.com/v1_1/frincks-cdn/resources/image
gives me (with the correct credentials:)
{"error":{"message":"Media Optimization Customer doesn't have sufficient permissions to access this endpoint"}}
Hi Cristian,
I just replied in the direct ticket but I'll also include the response below for reference:
There's an issue on our side with the message returned from the API and the endpoint recommended for use via Media Optimizer when your cloud's region is either in EU or AP. In your case, the endpoint you will want to use is
https://mo-api-eu.cloudinary.com
.Please sign in to leave a comment.