Manage Applications

    Copy a folder

    Copy a folder

    To copy a folder in Box you will need to provide our API with the id of the parent folder that you would like to copy the folder into.

    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 } }
            */
        });

    Optionally, you can provide a different name for the new folder.

    Node
    client.folders.copy('12345', '0', {name: 'Renamed folder'})
        .then(folderCopy => {
            // ...
        });