Skip to content

Renaming a File/Directory



Endpoint URL

The is a subdomain assigned to your application. For more information see the Client-side Setup section of this documentation.

Request headers

Content-Type: application/json  
user-token: optional value obtained as a result of the login operation.


Argument                Description
Content-Type Must be set to application/json. This header is mandatory.
user-token Optional header. Contains a value returned by Backendless in a preceding user Login API call. If user-token is set in the request, the currently logged in user will be assigned to the ownerId property of the user object which is being saved.  Additionally, the operation will be executed with the security policy associated currently logged in user. This means all permissions associated with the user and the roles assigned to the user will be enforced by Backendless.

Request Body:

A JSON object identifying a file or directory to be renamed and the new name:

  "oldPathName" : current-name,  
  "newName": new-name  


Argument                Description
current-name A path identifying file or directory to be renamed. The path must start with the root directory for the file storage allocated to the application.
new-name New name for the file or directory.

Return value

Absolute path of the renamed file or directory.


The example below describes how to rename a file called readme.txt located in the /documentation directory to readme-first.txt:


Make sure to replace xxxx in the domain name in the sample request below to the one assigned to your application.

curl -H Content-Type: application/json -X PUT \   
-v \  
-d "{ \"oldPathName\":\"/documentation/readme.txt\", \"newName\":\"readme-first.txt\" }"


When the backend reports an error, it returns a JSON object in the following format:


The server may return the following errors:

Error Code
Error message
User has no permissions to specified resource
Occurs when the user (anonymous or logged in) has no permission to modify the file
File or directory cannot be found.
Occurs when the source file/directory cannot be found.
Path contains prohibited symbols: {path name}

The specified resource was not found
Occurs when the API requests to rename a non-existent file or a directory.
Unable to modify file/folder: file/folder already exists: {file/directory name}
Occurs when the target file/directory already exists.
Parameter {param name} cannot be null
Occurs when one of the parameters is null.
Missing field {field name}
Occurs in REST APIs when one of the required fields is missing in the body.

Codeless Reference



Argument                Description
current path A path identifying file or directory to be renamed. The path must start with the root directory of the remote file storage.
new name New name for the file or directory.
return URL of the renamed directory/file When this box is checked, the operation returns a URL to the renamed file or directory.

Returns the URL to the renamed file or directory

Consider the following file stored in the notes directory:


The example below renames the "grocery.txt" file to "buy_food.txt". The same operation can be also applied to a folder, not only to a file.


The result of this operation will look as shown below after the Codeless logic runs: