Rename file

Rename file API


You can programmatically rename an already existing file in the media library using rename file API. This operation would rename all file versions of the file. Note: The old URLs will stop working. The file/file version URLs cached on CDN will continue to work unless a purge is requested.





base64 encoding of your_private_api_key:

Note the colon in the end.

Request Body




The full path of the file you want to rename. For example - /path/to/file.jpg



The new name of the file. A filename can contain:

- Alphanumeric Characters: a-z, A-Z, 0-9 (including Unicode letters, marks, and numerals in other languages).

- Special Characters: ., _, and -.

Any other character, including space, will be replaced by _.



Option to purge cache for the old file URL. When set to true, it will internally issue a purge cache request on CDN to remove cached content on the old URL. E.g. if an old file was accessible at -, a purge cache request will be issued to remove the CDN cache for this URL. This purge request is counted against your monthly purge quota. Note: Cache will be purged only for the current version of file.

Default value - false

// When purgeCache is set to true
    purgeRequestId: "598821f949c0a938d57563bd"

// When purgeCache is not set or set to false, response is empty

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.

// When purgeCache is set to true, we send the purge request ID.
// You can use this to get purge status
    purgeRequestId: "598821f949c0a938d57563bd"


Here is an example request to understand API usage.

curl -X PUT "" \
-H 'Content-Type: application/json' \
-u your_private_key: -d '
	"filePath" : "/path/to/old-file-name.jpg",
	"newFileName" : "new-file-name.jpg",
	"purgeCache": false

Last updated