Delete file

You can programmatically delete uploaded files in media library using delete file API.

When you delete a file, all its transformations are also deleted. However, if a file or specific transformation has been requested in the past, then the response is cached in CDN. You can purge the cache from the CDN using purge API.

delete
Delete file API

https://api.imagekit.io/v1/files/:fileId
Deletes a file and all its transformations.
Request
Response
Request
Path Parameters
fileId
required
string
The unique fileId of the uploaded file. fileId is returned in list files API and upload API
Headers
Authorization
required
string
base64 encoding of your_private_api_key: Note the colon in the end.
Response
200: OK
​

Response structure and status code

In case of error, you will get an error code along with the error message. On success, you will receive a 204 status code with empty body.

Examples

Here is the example request to understand the API usage.

cURL
cURL
# 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/fileId" \
-u your_private_key: