PHP Extension Box: Delete Folder

Back to Index

Move a folder to the trash. The recursive parameter must be included in order to delete folders that aren't empty. This example deletes the folder w/ id = 47885473705. An empty 204 response will be returned upon successful deletion. An error is thrown if the folder is not empty and the ‘recursive’ parameter is not included.


CURL Command

curl \
-H "Authorization: Bearer BOX_ACCESS_TOKEN" \

PHP Extension Example


// The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number.
// For example, if using Chilkat v9.5.0.48, then include as shown here:

$rest = new CkRest();

//  URL:
$bTls = true;
$port = 443;
$bAutoReconnect = true;
$success = $rest->Connect('',$port,$bTls,$bAutoReconnect);
if ($success != true) {
    print 'ConnectFailReason: ' . $rest->get_ConnectFailReason() . "\n";
    print $rest->lastErrorText() . "\n";

$rest->AddHeader('Authorization','Bearer BOX_ACCESS_TOKEN');

$sbResponseBody = new CkStringBuilder();
$success = $rest->FullRequestNoBodySb('DELETE','/2.0/folders/47885473705?recursive=true',$sbResponseBody);
if ($success != true) {
    print $rest->lastErrorText() . "\n";