POST
/
boxes
/
{boxId}
/
fs
/
rename
JavaScript
import GboxSDK from "gbox-sdk";

const gboxSDK = new GboxSDK({
  apiKey: process.env["GBOX_API_KEY"] // This is the default and can be omitted
});

async function main() {
  const box = await gboxSDK.create({ type: "linux" });

  // Rename a file
  const renameResult = await box.fs.rename({
    oldPath: "/home/user/old_file.txt",
    newPath: "/home/user/new_file.txt"
  });

  console.log("File renamed successfully:", renameResult.message);

  // Move and rename a file
  const moveResult = await box.fs.rename({
    oldPath: "/home/user/document.pdf",
    newPath: "/home/user/documents/renamed_document.pdf"
  });

  console.log("File moved and renamed successfully:", moveResult.message);
}

main();
{
  "type": "file",
  "name": "example.txt",
  "path": "/path/to/example.txt",
  "size": "10MB",
  "mode": "755",
  "lastModified": "2021-01-01T00:00:00Z"
}

Authorizations

Authorization
string
header
required

Enter your API Key in the format: Bearer <token>. Get it from https://gbox.ai

Path Parameters

boxId
string
required

Box ID

Example:

"c9bdc193-b54b-4ddb-a035-5ac0c598d32d"

Body

application/json

Request parameters for renaming a file/directory

Response

200
application/json

Rename file

File system file representation