Delete files (bulk)
You can programmatically delete multiple files uploaded in the media library using bulk file delete API.
If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge API.
post
https://api.imagekit.io
/v1/files/batch/deleteByFileIds
Bulk file delete API

Response structure and status code

In case of an error, you will get an error code along with the error message. On success, you will receive a 200 status code with JSON encoded response containing information about successfully deleted fileIds.

Examples

Here is the example request to understand the API usage.
cURL
Node.js
Python
PHP
Java
Ruby
1
# Array of the unique fileId of the uploaded files. fileId is returned in response of list files API and upload API.
2
curl -X POST "https://api.imagekit.io/v1/files/batch/deleteByFileIds" \
3
-H 'Content-Type: application/json' \
4
-u your_private_key: -d '
5
{
6
"fileIds" : ["5e1c2079c55ec3437c451b6d"]
7
}
8
'
Copied!
1
imagekit.bulkDeleteFiles(["fileId1","fileId2"])
2
.then(response => {
3
console.log(response);
4
})
5
.catch(error => {
6
console.log(error);
7
});
Copied!
1
imagekit.bulk_file_delete(["file_id1", "file_id2"])
Copied!
1
$imageKit->bulkFileDeleteByIds(array(
2
"fileIds" => array("file_id_1", "file_id_2")
3
));
Copied!
1
List<String> fileIds=new ArrayList<>();
2
fileIds.add("fileId1");
3
fileIds.add("fileId2");
4
ResultFileDelete result=ImageKit.getInstance().bulkDeleteFiles(fileIds);
Copied!
1
imagekitio = ImageKitIo::Client.new("your_private_key", "your_public_key", "your_url_endpoint")
2
bulk_ids = Array["fileId1","fileId2"]
3
imagekitio.delete_bulk_files(file_ids: bulk_ids)
Copied!
Last modified 1mo ago