Delete file

You can programmatically delete uploaded files in the media library using delete file 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.

Delete file API

DELETE https://api.imagekit.io/v1/files/:fileId

Deletes a file and all its versions from the media library.

Path Parameters

NameTypeDescription

fileId

string

The unique fileId of the uploaded file. fileId is returned in list files API and upload API.

Headers

NameTypeDescription

Authorization

string

base64 encoding of your_private_api_key:

Note the colon in the end.

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 204 status code with an empty body.

Examples

Here is the example request to understand the API usage.

# The unique fileId of the uploaded file. fileId is returned in response of list files API and upload API.
curl -X DELETE "https://api.imagekit.io/v1/files/file_id" \
-u your_private_key:

Last updated