Copy folder

post
https://api.box.com/2.0
/folders/:folder_id/copy

Creates a copy of a folder within a destination folder.

The original folder will not be changed.

Request

application/json

Path Parameters

stringin pathrequired
0

The unique identifier of the folder to copy.

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 with the ID 0 can not be copied.

Query Parameters

string arrayin queryoptional
id,type,name

A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.

Be aware that specifying this parameter will have the effect that none of the standard fields are returned in the response unless explicitly specified, instead only fields for the mini representation are returned, additional to the fields requested.

Request Body

stringin bodyoptional
New Folder255

An optional new name for the copied folder.

There are some restrictions to the file name. Names containing non-printable ASCII characters, forward and backward slashes (/, \), as well as names with trailing spaces are prohibited.

Additionally, the names . and .. are not allowed either.

objectin body

The destination folder to copy the folder to.

stringnulloptional
0

The ID of parent folder

Response

application/jsonFolder

Returns a new folder object representing the copied folder.

Not all available fields are returned by default. Use the fields query parameter to explicitly request any specific fields.

none

Returns an empty response when the If-None-Match header matches the current etag value of the folder. This indicates that the folder has not changed since it was last requested.

application/jsonClient error

Returns an error if some of the parameters are missing or not valid.

  • bad_request when a parameter is missing.
  • item_name_too_long when the new folder name is too long.
application/jsonClient error

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

  • not_found when the authenticated user does not have access to the parent folder
application/jsonClient error

Returns an error if a folder by this name already exists in the destination folder, or if the destination folder is locked.

  • item_name_in_use when a folder with the same name already exists.
application/jsonClient error

Returns an error when trying to copy the root folder.

application/jsonClient error

An unexpected client error.

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

Request Example

cURL
curl -X POST https://api.box.com/2.0/folders/4353455/copy \
     -H 'Authorization: Bearer <ACCESS_TOKEN>'
     -H 'Content-Type: application/json" '
     -d '{
       "parent": {
         "id": "345345"
       }
     }'
.NET
// Copy folder 11111 into folder 22222
var requestParams = new BoxFolderRequest()
{
    Id = "11111",
    Parent = new BoxRequestEntity()
    {
        Id = "22222"
    }
};
BoxFolder folderCopy = await client.FoldersManager.CopyAsync(requestParams);
Java
BoxFolder folder = new BoxFolder(api, "id1");
BoxFolder destination = new BoxFolder(api, "id2");
folder.copy(destination);
Python
folder_id = '22222'
destination_folder_id = '44444'

folder_to_copy = client.folder(folder_id)
destination_folder = client.folder(destination_folder_id)

folder_copy = folder_to_copy.copy(destination_folder)
print('Folder "{0}" has been copied into folder "{1}"'.format(folder_copy.name, folder_copy.parent.name))
Node
client.folders.copy('11111', '22222')
    .then(folderCopy => {
       /* folderCopy -> {
            type: 'folder',
            id: '1234567',
            sequence_id: '0',
            etag: '0',
            name: 'Pictures from 2017',
            created_at: '2012-12-12T10:53:43-08:00',
            modified_at: '2012-12-12T11:15:04-08:00',
            description: 'Some pictures I took',
            size: 629644,
            path_collection: 
            { total_count: 1,
                entries: 
                [ { type: 'folder',
                    id: '0',
                    sequence_id: null,
                    etag: null,
                    name: 'All Files' },
                  { type: 'folder',
                    id: '22222',
                    sequence_id: '3',
                    etag: '3',
                    name: 'Archives' } ] },
            created_by: 
            { type: 'user',
                id: '22222',
                name: 'Example User'
                login: 'user@example.com' },
            modified_by: 
            { type: 'user',
                id: '22222',
                name: 'Example User',
                login: 'user@example.com' },
            owned_by: 
            { type: 'user',
                id: '22222',
                name: 'Example User',
                login: 'user@example.com' },
            shared_link: null,
            parent: 
            { type: 'folder',
                id: '22222',
                sequence_id: '3',
                etag: '3',
                name: 'Archives' },
            item_status: 'active',
            item_collection: 
            { total_count: 1,
                entries: 
                [ { type: 'file',
                    id: '44444',
                    sequence_id: '0',
                    etag: '0',
                    sha1: '134b65991ed521fcfe4724b7d814ab8ded5185dc',
                    name: 'tigers.jpeg' } ],
                offset: 0,
                limit: 100 } }
        */
    });
iOS
client.folders.copy(
    folderId: "22222",
    destinationFolderID: "12345"
) { (result: Result<Folder, BoxSDKError>) in
    guard case let .success(folderCopy) = result else {
        print("Error copying folder")
        return
    }

    print("Copied folder \(folderCopy.name) to destination \(folderCopy.parent?.name)")
}