Rename file
put
https://api.imagekit.io
/v1/files/rename
Rename file 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 the JSON-encoded response body.
The response depends upon the value of purgeCache in the request. If purgeCache is set to true, the response contains purgeRequestId, which can be used to get the purge cache status.
purgeCache=true
purgeCache=false or unset
1
// When purgeCache is set to true, we send the purge request ID.
2
// You can use this to get purge status
3
{
4
purgeRequestId: "598821f949c0a938d57563bd"
5
}
Copied!
1
// When purgeCache is set to false or not set
2
{}
Copied!

Example

Here is an example request to understand API usage.
cURL
1
curl -X PUT "https://api.imagekit.io/v1/files/rename" \
2
-H 'Content-Type: application/json' \
3
-u your_private_key: -d '
4
{
5
"filePath" : "/path/to/old-file-name.jpg",
6
"newFileName" : "new-file-name.jpg",
7
"purgeCache": false
8
}
9
'
Copied!
Last modified 4mo ago