There are a few ways to delete images via the UI and API.
Via API
- Delete a single image using the Upload API Destroy method
- Delete multiple images using the Admin API Delete Resources method
Via UI
Via API
Delete a single image using the Upload API Destroy method
Deleting a single image can be done using the Upload API Destroy method, 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 images using the Admin API Delete Resources method
Deleting multiple images can be done using the Admin API, and our client SDKs also provide methods to call this API from your application code.
For example, using our Node JS SDK, a simple call to delete 2 images called zombie
and human
is:
cloudinary.api.delete_resources(['zombie','human'], function(result) { console.log(result) });
You can try this below using your own account details
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, tag, 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 not required anymore.
Via API
Delete images individually
- Click on the Media Library tab
- In the search bar, select the
Asset types
filter then selectImage
or just search the asset directly - Find the asset then click on the overflow icon (the three dots) and select
Delete
Bulk delete images
- Go to your bulk delete page
- Select Originals and derived resources
- Under Search by, go to the last section and set:
Resource type
toImage
Type
to the one of your choices
You will then receive an email when the operation is completed.
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.