Delete folder

delete
https://api.box.com/2.0
/folders/:folder_id

Deletes a folder, either permanently or by moving it to the trash.

Request

application/json

Path Parameters

stringin pathrequired
0

The unique identifier that represent a folder.

The ID for any folder can be determined by visiting this folder in the web application and copying the ID from the URL. For example, for the URL https://*.app.box.com/folder/123 the folder_id is 123.

The root folder of a Box account is always represented by the ID 0.

Query Parameters

booleanin queryoptional
true

Delete a folder that is not empty by recursively deleting the folder and all of its content.

Request Headers

stringin header
optional
1

Ensures this item hasn't recently changed before making changes.

Pass in the item's last observed etag value into this header and the endpoint will fail with a 412 Precondition Failed if it has changed since.

Response

none

Returns an empty response when the folder is successfully deleted or moved to the trash.

application/jsonClient error

Returns an error if the user does not have the required access to perform the action.

  • access_denied_insufficient_permissions: Returned when the user does not have access to the folder.
  • insufficient_scope: Returned an error if the application does not have the right scope to delete folders. Make sure your application has been configured to read and write all files and folders stored in Box.
application/jsonClient error

Returns an error if the folder could not be found, or the authenticated user does not have access to the folder.

  • not_found when the authenticated user does not have access to the folder.
application/jsonClient error
  • folder_not_empty: Returned if the folder is not empty. Use the recursive query parameter to recursively delete the folder and its contents.
  • operation_blocked_temporary: Returned if the folder is locked due to another move, copy, delete or restore operation in progress.

    The operation can be retried at a later point.

application/jsonClient error

Returns an error when the If-Match header does not match the current etag value of the folder. This indicates that the folder has changed since it was last requested.

application/jsonClient error

Returns an error when the operation takes longer than 60 seconds. The operation will continue after this response has been returned.

application/jsonClient error

An unexpected client error.

delete
Delete folder
You can now try out some of our APIs live, right here in the documentation.
Log in

Request Example

cURL
curl -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")
}