Restore File

Restore File

To restore a file that has been moved to the trash, but has not yet been purged, make a POST request to the /files/:file_id endpoint. This will place the file in the original folder if it is still available, or you optionally can specify a parent folder.

cURL
curl -i -X POST "https://upload.box.com/api/2.0/files/12345" \
     -H "Authorization: Bearer <ACCESS_TOKEN>" \
     -H "Content-Type: application/json" \
Java
String fileID = "125367";
String newName = "Presentation 2018 ORIGINAL.pptx";
String newParentID = "98765";

BoxTrash trash = new BoxTrash(api);
// Avoid conflicts at the original location
trash.restoreFile(fileID, newName, newParentID);
Python
file_to_restore = client.file(file_id='11111')
restored_file = client.trash().restore_item(file_to_restore)
print('File ID is {0} and name is {1}'.format(restored_file.id, restored_file.name))