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.

Bulk file delete API

POST https://api.imagekit.io/v1/files/batch/deleteByFileIds

Deletes multiple files and their versions from the media library.

Headers

NameTypeDescription

Authorization

string

base64 encoding of your_private_api_key:

Note the colon in the end.

Request Body

NameTypeDescription

fileIds

array

Each value should be a unique fileId of the uploaded file. fileId is returned in list files API and upload API.

{
    "successfullyDeletedFileIds": [
        "5e1c13d0c55ec3437c451406",
        ...
    ]
}

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.

# Array of the unique fileId of the uploaded files. fileId is returned in response of list files API and upload API.
curl -X POST "https://api.imagekit.io/v1/files/batch/deleteByFileIds" \
-H 'Content-Type: application/json' \
-u your_private_key: -d '
{
	"fileIds" : ["file_id_1", "file_id_2"]
}
'

Last updated