Skip to main content
Question

Rename File using Box API

  • May 23, 2025
  • 2 replies
  • 12 views

Forum|alt.badge.img

Hi Gurus,

I have a requirement to rename files in Box having specific delimiters and extension  in the file name, though renaming is a option in the front end, I did not see a Box API which I can leverage to perform the same action (I would need to do this dynamically every time a file is posted to Box). Any help / ideas on the same would be highly appreciated.

Thanks and Regards, Sidd.

2 replies

Forum|alt.badge.img

Hi Siddhartha,

You can make a PUT call to the files API, specifying the name, see here.

And the curl example:

curl -i -X PUT "https://upload.box.com/api/2.0/files/12345" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{ "name": "New name" }'

Not sure what tools you are using, but this is implemented both on the CLI and the SDK's

CLI example:

❯ box folders:items 0 --fields type,id,name --csv
type,id,name
...
folder,169047753928,UI Elements Demo
file,1039371254466,upload_file.py

❯ box files:rename 1039371254466 my_new_uploaded_file.py --fields type,id,name --csv
type,id,name
file,1039371254466,my_new_uploaded_file.py

❯ box folders:items 0 --fields type,id,name --csv
type,id,name
...
folder,169047753928,UI Elements Demo
file,1039371254466,my_new_uploaded_file.py

Forum|alt.badge.img

Hi Rui- Im sorry I am not following.  Help!