Add the power of the Box AI API to your custom apps at Content Cloud Summit on May 15

Learn more and register!

Delete Folder

Delete Folder

To remove a folder in Box you will need to provide our API with the ID of the folder.

cURL
curl -i -X DELETE "https://api.box.com/2.0/folders/4353455" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
.NET
await client.FoldersManager.DeleteAsync("11111", recursive: true);
Java
// Delete the folder and all its contents
BoxFolder folder = new BoxFolder(api, "id");
folder.delete(true);
Python
client.folder(folder_id='22222').delete()
Node
client.folders.delete('12345', {recursive: true})
    .then(() => {
        // deletion succeeded — no value returned
    });
iOS
client.folders.delete(folderId: "22222", recursive: true) { result: Result<Void, BoxSDKError>} in
    guard case .success = result else {
        print("Error deleting folder")
        return
    }

    print("Folder and contents successfully deleted")
}
TypeScript (Beta)
await client.folders.deleteFolderById(folder1.id);
Python (Beta)
client.folders.delete_folder_by_id(folder_1.id)
.NET (Beta)
await client.Folders.DeleteFolderByIdAsync(folderId: folder1.Id);

Deleting non-empty folders

This API returns an error if the folder is not empty. When deleting a folder, you can pass in the recursive parameter to force a folder to be deleted even if it is not empty. This will delete all items within this folder, including any of their descendants.

Folder locking

The enterprise settings determine whether the folder will be permanently deleted from Box or moved to the trash.

During this operation, part of the file tree will be locked, mainly the source folder and all of its descendants.

For the duration of the operation, no other move, copy, delete, or restore operation can performed on any of the locked folders.

Timeout

Timeout for this operation is 60 seconds. The operation will include after a HTTP 503 has been returned.