Class: Folders

Folders(client) → {void}

Simple manager for interacting with all 'Folder' endpoints and actions.

Constructor

new Folders(client) → {void}

Parameters:
Name Type Description
client BoxClient The Box API Client that is responsible for making calls to the API
Source:
Returns:
Type
void

Methods

addMetadata(folderID, scope, template, data, callbackopt) → {Promise.<Object>}

Adds metadata to a folder. Metadata must either match a template schema or be placed into the unstructured "properties" template in global scope. API Endpoint: '/folders/:folderID/metadata/:scope/:template' Method: POST
Parameters:
Name Type Attributes Description
folderID string The ID of the folder to add metadata to
scope string The scope of the metadata template, e.g. "enterprise"
template string The metadata template schema to add
data Object Key/value pairs to add as metadata
callback function <optional>
Called with error if unsuccessful
Source:
Returns:
A promise resolving to the created metadata
Type
Promise.<Object>

addMetadata(folderID, scope, template, data, callbackopt) → {Promise.<Object>}

Adds metadata to a folder. Metadata must either match a template schema or be placed into the unstructured "properties" template in global scope. API Endpoint: '/folders/:folderID/metadata/:scope/:template' Method: POST
Parameters:
Name Type Attributes Description
folderID string The ID of the folder to add metadata to
scope string The scope of the metadata template, e.g. "enterprise"
template string The metadata template schema to add
data Object Key/value pairs to add as metadata
callback function <optional>
Called with error if unsuccessful
Source:
Returns:
A promise resolving to the created metadata
Type
Promise.<Object>

addToCollection(folderID, collectionID, callbackopt) → {Promise.<Object>}

Add a folder to a given collection API Endpoint: '/folders/:folderID' Method: PUT
Parameters:
Name Type Attributes Description
folderID string The folder to add to the collection
collectionID string The collection to add the folder to
callback function <optional>
Passed the updated folder if successful, error otherwise
Source:
Returns:
A promise resolving to the updated folder object
Type
Promise.<Object>

addToCollection(folderID, collectionID, callbackopt) → {Promise.<Object>}

Add a folder to a given collection API Endpoint: '/folders/:folderID' Method: PUT
Parameters:
Name Type Attributes Description
folderID string The folder to add to the collection
collectionID string The collection to add the folder to
callback function <optional>
Passed the updated folder if successful, error otherwise
Source:
Returns:
A promise resolving to the updated folder object
Type
Promise.<Object>

applyWatermark(folderID, optionsopt, callbackopt) → {Promise.<Object>}

Used to apply or update the watermark for a corresponding Box folder. API Endpoint: '/folders/:folderID/watermark' Method: PUT
Parameters:
Name Type Attributes Description
folderID string The Box ID of the folder to update watermark for
options Object <optional>
Optional parameters, can be left null
callback function <optional>
Passed the watermark information if successful, error otherwise
Source:
Returns:
A promise resolving to the watermark info
Type
Promise.<Object>

applyWatermark(folderID, optionsopt, callbackopt) → {Promise.<Object>}

Used to apply or update the watermark for a corresponding Box folder. API Endpoint: '/folders/:folderID/watermark' Method: PUT
Parameters:
Name Type Attributes Description
folderID string The Box ID of the folder to update watermark for
options Object <optional>
Optional parameters, can be left null
callback function <optional>
Passed the watermark information if successful, error otherwise
Source:
Returns:
A promise resolving to the watermark info
Type
Promise.<Object>

copy(folderID, newParentID, optionsopt, callbackopt) → {Promise.<Object>}

Copy a folder into a new, different folder API Endpoint: '/folders/:folderID/copy Method: POST
Parameters:
Name Type Attributes Description
folderID string The Box ID of the folder being requested
newParentID string The Box ID for the new parent folder. '0' to copy to All Files.
options Object <optional>
Optional parameters for the copy operation, can be left null in most cases
Properties
Name Type Attributes Description
name string <optional>
A new name to use if there is an identically-named item in the new parent folder
callback function <optional>
passed the new folder info if call was successful
Source:
Returns:
A promise resolving to the new folder object
Type
Promise.<Object>

copy(folderID, newParentID, optionsopt, callbackopt) → {Promise.<Object>}

Copy a folder into a new, different folder API Endpoint: '/folders/:folderID/copy Method: POST
Parameters:
Name Type Attributes Description
folderID string The Box ID of the folder being requested
newParentID string The Box ID for the new parent folder. '0' to copy to All Files.
options Object <optional>
Optional parameters for the copy operation, can be left null in most cases
Properties
Name Type Attributes Description
name string <optional>
A new name to use if there is an identically-named item in the new parent folder
callback function <optional>
passed the new folder info if call was successful
Source:
Returns:
A promise resolving to the new folder object
Type
Promise.<Object>

create(parentFolderID, name, callbackopt) → {Promise.<Object>}

Creates a new Folder within a parent folder API Endpoint: '/folders Method: POST
Parameters:
Name Type Attributes Description
parentFolderID string Box folder id of the folder to add into
name string The name for the new folder
callback function <optional>
passed the new folder info if call was successful
Source:
Returns:
A promise resolving to the created folder object
Type
Promise.<Object>

create(parentFolderID, name, callbackopt) → {Promise.<Object>}

Creates a new Folder within a parent folder API Endpoint: '/folders Method: POST
Parameters:
Name Type Attributes Description
parentFolderID string Box folder id of the folder to add into
name string The name for the new folder
callback function <optional>
passed the new folder info if call was successful
Source:
Returns:
A promise resolving to the created folder object
Type
Promise.<Object>

delete(folderID, optionsopt, callbackopt) → {Promise.<void>}

Delete a given folder. API Endpoint: '/folders/:folderID' Method: DELETE
Parameters:
Name Type Attributes Description
folderID string Box ID of the folder being requested
options Object <optional>
Additional options for the request. Can be left null in most cases.
Properties
Name Type Attributes Description
etag string <optional>
Only delete the folder if the ETag matches
callback function <optional>
Empty response body passed if successful.
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

delete(folderID, optionsopt, callbackopt) → {Promise.<void>}

Delete a given folder. API Endpoint: '/folders/:folderID' Method: DELETE
Parameters:
Name Type Attributes Description
folderID string Box ID of the folder being requested
options Object <optional>
Additional options for the request. Can be left null in most cases.
Properties
Name Type Attributes Description
etag string <optional>
Only delete the folder if the ETag matches
callback function <optional>
Empty response body passed if successful.
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

deleteLock(folderLockID, callbackopt) → {Promise.<void>}

Used to delete a lock on a folder. API Endpoint: '/folder_locks/:folderLockID' Method: DELETE
Parameters:
Name Type Attributes Description
folderLockID string The Box ID of the folder lock
callback function <optional>
Empty response body passed if successful, error otherwise
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

deleteLock(folderLockID, callbackopt) → {Promise.<void>}

Used to delete a lock on a folder. API Endpoint: '/folder_locks/:folderLockID' Method: DELETE
Parameters:
Name Type Attributes Description
folderLockID string The Box ID of the folder lock
callback function <optional>
Empty response body passed if successful, error otherwise
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

deleteMetadata(folderID, scope, template, callbackopt) → {Promise.<void>}

Deletes a metadata template from a folder. API Endpoint: '/folders/:folderID/metadata/:scope/:template' Method: DELETE
Parameters:
Name Type Attributes Description
folderID string The ID of the folder to remove metadata from
scope string The scope of the metadata template
template string The template to remove from the folder
callback function <optional>
Called with nothing if successful, error otherwise
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

deleteMetadata(folderID, scope, template, callbackopt) → {Promise.<void>}

Deletes a metadata template from a folder. API Endpoint: '/folders/:folderID/metadata/:scope/:template' Method: DELETE
Parameters:
Name Type Attributes Description
folderID string The ID of the folder to remove metadata from
scope string The scope of the metadata template
template string The template to remove from the folder
callback function <optional>
Called with nothing if successful, error otherwise
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

deletePermanently(folderID, optionsopt, callbackopt) → {Promise.<void>}

Permanently deletes an folder that is in the trash. The item will no longer exist in Box. This action cannot be undone API Endpoint: '/folders/:folderID/trash' Method: DELETE
Parameters:
Name Type Attributes Description
folderID string Box ID of the folder being requested
options Object <optional>
Optional parameters
Properties
Name Type Attributes Description
etag string <optional>
Only delete the folder if the ETag matches
callback function <optional>
Called with nothing if successful, error otherwise
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

deletePermanently(folderID, optionsopt, callbackopt) → {Promise.<void>}

Permanently deletes an folder that is in the trash. The item will no longer exist in Box. This action cannot be undone API Endpoint: '/folders/:folderID/trash' Method: DELETE
Parameters:
Name Type Attributes Description
folderID string Box ID of the folder being requested
options Object <optional>
Optional parameters
Properties
Name Type Attributes Description
etag string <optional>
Only delete the folder if the ETag matches
callback function <optional>
Called with nothing if successful, error otherwise
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

get(folderID, optionsopt, callbackopt) → {Promise.<Object>}

Requests a folder object with the given ID. API Endpoint: '/folders/:folderID' Method: GET
Parameters:
Name Type Attributes Description
folderID string Box ID of the folder being requested
options Object <optional>
Additional options for the request. Can be left null in most cases.
callback function <optional>
Passed the folder information if it was acquired successfully
Source:
Returns:
A promise resolving to the folder object
Type
Promise.<Object>

get(folderID, optionsopt, callbackopt) → {Promise.<Object>}

Requests a folder object with the given ID. API Endpoint: '/folders/:folderID' Method: GET
Parameters:
Name Type Attributes Description
folderID string Box ID of the folder being requested
options Object <optional>
Additional options for the request. Can be left null in most cases.
callback function <optional>
Passed the folder information if it was acquired successfully
Source:
Returns:
A promise resolving to the folder object
Type
Promise.<Object>

getAllMetadata(folderID, callbackopt) → {Promise.<Object>}

Retrieves all metadata associated with a folder. API Endpoint: '/folders/:folderID/metadata' Method: GET
Parameters:
Name Type Attributes Description
folderID string the ID of the folder to get metadata for
callback function <optional>
called with an array of metadata when successful
Source:
Returns:
A promise resolving to the collection of metadata on the folder
Type
Promise.<Object>

getAllMetadata(folderID, callbackopt) → {Promise.<Object>}

Retrieves all metadata associated with a folder. API Endpoint: '/folders/:folderID/metadata' Method: GET
Parameters:
Name Type Attributes Description
folderID string the ID of the folder to get metadata for
callback function <optional>
called with an array of metadata when successful
Source:
Returns:
A promise resolving to the collection of metadata on the folder
Type
Promise.<Object>

getCollaborations(folderID, optionsopt, callbackopt) → {Promise.<schemas.Collaborations>}

Requests collaborations on a given folder. API Endpoint: '/folders/:folderID/collaborations' Method: GET
Parameters:
Name Type Attributes Description
folderID string Box ID of the folder being requested
options Object <optional>
Additional options for the request. Can be left null in most cases.
callback function <optional>
Passed the folder information if it was acquired successfully
Source:
Returns:
A promise resolving to the collection of collaborations
Type
Promise.<schemas.Collaborations>

getCollaborations(folderID, optionsopt, callbackopt) → {Promise.<schemas.Collaborations>}

Requests collaborations on a given folder. API Endpoint: '/folders/:folderID/collaborations' Method: GET
Parameters:
Name Type Attributes Description
folderID string Box ID of the folder being requested
options Object <optional>
Additional options for the request. Can be left null in most cases.
callback function <optional>
Passed the folder information if it was acquired successfully
Source:
Returns:
A promise resolving to the collection of collaborations
Type
Promise.<schemas.Collaborations>

getItems(folderID, optionsopt, callbackopt) → {Promise.<Object>}

Requests items contained within a given folder. API Endpoint: '/folders/:folderID/items' Method: GET
Parameters:
Name Type Attributes Description
folderID string Box ID of the folder being requested
options Object <optional>
Additional options for the request. Can be left null in most cases.
callback function <optional>
Passed the folder information if it was acquired successfully
Source:
Returns:
A promise resolving to the collection of the items in the folder
Type
Promise.<Object>

getItems(folderID, optionsopt, callbackopt) → {Promise.<Object>}

Requests items contained within a given folder. API Endpoint: '/folders/:folderID/items' Method: GET
Parameters:
Name Type Attributes Description
folderID string Box ID of the folder being requested
options Object <optional>
Additional options for the request. Can be left null in most cases.
callback function <optional>
Passed the folder information if it was acquired successfully
Source:
Returns:
A promise resolving to the collection of the items in the folder
Type
Promise.<Object>

getLocks(folderID, callbackopt) → {Promise.<void>}

Used to get all locks on a folder. API Endpoint: '/folder_locks' Method: GET
Parameters:
Name Type Attributes Description
folderID string The Box ID of the folder to lock
callback function <optional>
Passed a collection of folder lock objects if successful, error otherwise
Source:
Returns:
A promise resolving to a collection of folder lock objects
Type
Promise.<void>

getLocks(folderID, callbackopt) → {Promise.<void>}

Used to get all locks on a folder. API Endpoint: '/folder_locks' Method: GET
Parameters:
Name Type Attributes Description
folderID string The Box ID of the folder to lock
callback function <optional>
Passed a collection of folder lock objects if successful, error otherwise
Source:
Returns:
A promise resolving to a collection of folder lock objects
Type
Promise.<void>

getMetadata(folderID, scope, template, callbackopt) → {Promise.<Object>}

Retrieve a single metadata template instance for a folder. API Endpoint: '/folders/:folderID/metadata/:scope/:template' Method: GET
Parameters:
Name Type Attributes Description
folderID string The ID of the folder to retrive the metadata of
scope string The scope of the metadata template, e.g. "global"
template string The metadata template to retrieve
callback function <optional>
Passed the metadata template if successful
Source:
Returns:
A promise resolving to the metadata template
Type
Promise.<Object>

getMetadata(folderID, scope, template, callbackopt) → {Promise.<Object>}

Retrieve a single metadata template instance for a folder. API Endpoint: '/folders/:folderID/metadata/:scope/:template' Method: GET
Parameters:
Name Type Attributes Description
folderID string The ID of the folder to retrive the metadata of
scope string The scope of the metadata template, e.g. "global"
template string The metadata template to retrieve
callback function <optional>
Passed the metadata template if successful
Source:
Returns:
A promise resolving to the metadata template
Type
Promise.<Object>

getTrashedFolder(folderID, optionsopt, callbackopt) → {Promise.<Object>}

Retrieves a folder that has been moved to the trash API Endpoint: '/folders/:folderID/trash' Method: GET
Parameters:
Name Type Attributes Description
folderID string The ID of the folder being requested
options Object <optional>
Additional options for the request. Can be left null in most cases.
callback function <optional>
Passed the folder information if it was acquired successfully
Source:
Returns:
A promise resolving to the trashed folder object
Type
Promise.<Object>

getTrashedFolder(folderID, optionsopt, callbackopt) → {Promise.<Object>}

Retrieves a folder that has been moved to the trash API Endpoint: '/folders/:folderID/trash' Method: GET
Parameters:
Name Type Attributes Description
folderID string The ID of the folder being requested
options Object <optional>
Additional options for the request. Can be left null in most cases.
callback function <optional>
Passed the folder information if it was acquired successfully
Source:
Returns:
A promise resolving to the trashed folder object
Type
Promise.<Object>

getWatermark(folderID, optionsopt, callbackopt) → {Promise.<Object>}

Used to retrieve the watermark for a corresponding Box folder. API Endpoint: '/folders/:folderID/watermark' Method: GET
Parameters:
Name Type Attributes Description
folderID string The Box ID of the folder to get watermark for
options Object <optional>
Additional options for the request. Can be left null in most cases.
callback function <optional>
Passed the watermark information if successful, error otherwise
Source:
Returns:
A promise resolving to the watermark info
Type
Promise.<Object>

getWatermark(folderID, optionsopt, callbackopt) → {Promise.<Object>}

Used to retrieve the watermark for a corresponding Box folder. API Endpoint: '/folders/:folderID/watermark' Method: GET
Parameters:
Name Type Attributes Description
folderID string The Box ID of the folder to get watermark for
options Object <optional>
Additional options for the request. Can be left null in most cases.
callback function <optional>
Passed the watermark information if successful, error otherwise
Source:
Returns:
A promise resolving to the watermark info
Type
Promise.<Object>

lock(folderID, callbackopt) → {Promise.<void>}

Used to lock a Box folder. API Endpoint: '/folder_locks' Method: POST
Parameters:
Name Type Attributes Description
folderID string The Box ID of the folder to lock
callback function <optional>
Passed the folder lock object if successful, error otherwise
Source:
Returns:
A promise resolving to a folder lock object
Type
Promise.<void>

lock(folderID, callbackopt) → {Promise.<void>}

Used to lock a Box folder. API Endpoint: '/folder_locks' Method: POST
Parameters:
Name Type Attributes Description
folderID string The Box ID of the folder to lock
callback function <optional>
Passed the folder lock object if successful, error otherwise
Source:
Returns:
A promise resolving to a folder lock object
Type
Promise.<void>

move(folderID, newParentID, callbackopt) → {Promise.<Object>}

Move a folder into a new parent folder. API Endpoint: '/folders/:folderID' Method: PUT
Parameters:
Name Type Attributes Description
folderID string The Box ID of the folder being requested
newParentID string The Box ID for the new parent folder. '0' to move to All Files.
callback function <optional>
Passed the updated folder information if it was acquired successfully
Source:
Returns:
A promise resolving to the updated folder object
Type
Promise.<Object>

move(folderID, newParentID, callbackopt) → {Promise.<Object>}

Move a folder into a new parent folder. API Endpoint: '/folders/:folderID' Method: PUT
Parameters:
Name Type Attributes Description
folderID string The Box ID of the folder being requested
newParentID string The Box ID for the new parent folder. '0' to move to All Files.
callback function <optional>
Passed the updated folder information if it was acquired successfully
Source:
Returns:
A promise resolving to the updated folder object
Type
Promise.<Object>

removeFromCollection(folderID, collectionID, callbackopt) → {Promise.<Object>}

Remove a folder from a given collection API Endpoint: '/folders/:folderID' Method: PUT
Parameters:
Name Type Attributes Description
folderID string The folder to remove from the collection
collectionID string The collection to remove the folder from
callback function <optional>
Passed the updated folder if successful, error otherwise
Source:
Returns:
A promise resolving to the updated folder object
Type
Promise.<Object>

removeFromCollection(folderID, collectionID, callbackopt) → {Promise.<Object>}

Remove a folder from a given collection API Endpoint: '/folders/:folderID' Method: PUT
Parameters:
Name Type Attributes Description
folderID string The folder to remove from the collection
collectionID string The collection to remove the folder from
callback function <optional>
Passed the updated folder if successful, error otherwise
Source:
Returns:
A promise resolving to the updated folder object
Type
Promise.<Object>

removeWatermark(folderID, callbackopt) → {Promise.<void>}

Used to remove the watermark for a corresponding Box folder. API Endpoint: '/folders/:folderID/watermark' Method: DELETE
Parameters:
Name Type Attributes Description
folderID string The Box ID of the folder to remove watermark from
callback function <optional>
Empty response body passed if successful, error otherwise
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

removeWatermark(folderID, callbackopt) → {Promise.<void>}

Used to remove the watermark for a corresponding Box folder. API Endpoint: '/folders/:folderID/watermark' Method: DELETE
Parameters:
Name Type Attributes Description
folderID string The Box ID of the folder to remove watermark from
callback function <optional>
Empty response body passed if successful, error otherwise
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

restoreFromTrash(folderID, optionsopt, callbackopt) → {Promise.<Object>}

Restores an item that has been moved to the trash. Default behavior is to restore the item to the folder it was in before it was moved to the trash. If that parent folder no longer exists or if there is now an item with the same name in that parent folder, the new parent older and/or new name will need to be included in the request. API Endpoint: '/folders/:folderID' Method: POST
Parameters:
Name Type Attributes Description
folderID string The ID of the folder to restore
options Object <optional>
Optional parameters, can be left null
Properties
Name Type Attributes Description
name string <optional>
<nullable>
The new name for this item
parent_id string <optional>
The new parent folder for this item
callback function <optional>
Called with folder information if successful, error otherwise
Source:
Returns:
A promise resolving to the restored folder object
Type
Promise.<Object>

restoreFromTrash(folderID, optionsopt, callbackopt) → {Promise.<Object>}

Restores an item that has been moved to the trash. Default behavior is to restore the item to the folder it was in before it was moved to the trash. If that parent folder no longer exists or if there is now an item with the same name in that parent folder, the new parent older and/or new name will need to be included in the request. API Endpoint: '/folders/:folderID' Method: POST
Parameters:
Name Type Attributes Description
folderID string The ID of the folder to restore
options Object <optional>
Optional parameters, can be left null
Properties
Name Type Attributes Description
name string <optional>
<nullable>
The new name for this item
parent_id string <optional>
The new parent folder for this item
callback function <optional>
Called with folder information if successful, error otherwise
Source:
Returns:
A promise resolving to the restored folder object
Type
Promise.<Object>

setMetadata(folderID, scope, template, metadata, callbackopt) → {Promise.<Object>}

Sets metadata on a folder, overwriting any metadata that exists for the provided keys.
Parameters:
Name Type Attributes Description
folderID string The folder to set metadata on
scope string The scope of the metadata template
template string The key of the metadata template
metadata Object The metadata to set
callback function <optional>
Called with updated metadata if successful
Source:
Returns:
A promise resolving to the updated metadata
Type
Promise.<Object>

setMetadata(folderID, scope, template, metadata, callbackopt) → {Promise.<Object>}

Sets metadata on a folder, overwriting any metadata that exists for the provided keys.
Parameters:
Name Type Attributes Description
folderID string The folder to set metadata on
scope string The scope of the metadata template
template string The key of the metadata template
metadata Object The metadata to set
callback function <optional>
Called with updated metadata if successful
Source:
Returns:
A promise resolving to the updated metadata
Type
Promise.<Object>

update(folderID, updates, callbackopt) → {Promise.<Object>}

Update some information about a given folder. API Endpoint: '/folders/:folderID' Method: PUT
Parameters:
Name Type Attributes Description
folderID string The Box ID of the folder being requested
updates Object Folder fields to update
Properties
Name Type Attributes Description
etag string <optional>
Only update the folder if the ETag matches
fields string <optional>
Comma-separated list of fields to return
callback function <optional>
Passed the updated folder information if it was acquired successfully
Source:
Returns:
A promise resolving to the updated folder object
Type
Promise.<Object>

update(folderID, updates, callbackopt) → {Promise.<Object>}

Update some information about a given folder. API Endpoint: '/folders/:folderID' Method: PUT
Parameters:
Name Type Attributes Description
folderID string The Box ID of the folder being requested
updates Object Folder fields to update
Properties
Name Type Attributes Description
etag string <optional>
Only update the folder if the ETag matches
fields string <optional>
Comma-separated list of fields to return
callback function <optional>
Passed the updated folder information if it was acquired successfully
Source:
Returns:
A promise resolving to the updated folder object
Type
Promise.<Object>

updateMetadata(folderID, scope, template, patch, callbackopt) → {Promise.<Object>}

Updates a metadata template instance with JSON Patch-formatted data. API Endpoint: '/folders/:folderID/metadata/:scope/:template' Method: PUT
Parameters:
Name Type Attributes Description
folderID string The folder to update metadata for
scope string The scope of the template to update
template string The template to update
patch Object The patch data
callback function <optional>
Called with updated metadata if successful
Source:
Returns:
A promise resolving to the updated metadata
Type
Promise.<Object>

updateMetadata(folderID, scope, template, patch, callbackopt) → {Promise.<Object>}

Updates a metadata template instance with JSON Patch-formatted data. API Endpoint: '/folders/:folderID/metadata/:scope/:template' Method: PUT
Parameters:
Name Type Attributes Description
folderID string The folder to update metadata for
scope string The scope of the template to update
template string The template to update
patch Object The patch data
callback function <optional>
Called with updated metadata if successful
Source:
Returns:
A promise resolving to the updated metadata
Type
Promise.<Object>