Manage Applications

    Copy a 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.

    Asynchronous copying

    If the folder being copied contains up to 500 items the copy will happen synchronously with the API call. The call will not return until the copy operation has completed.

    If the folder contains more than 500 items the copy operation will be executed asynchronously and the API call will return directly yet before the copy operation has completed. We currently have no API to check when a copy operation has finished.

    Folder locking

    During this operation, part of the file tree will be locked, mainly the source folder and all of its descendants, as well as the destination folder.

    For the duration of the operation, no other move, copy, delete, or restore operation can performed on any of the locked folders. Most importantly, this means that the same folder can not be copied to two different parts of the folder tree at the same time.

    Metadata

    If the destination folder has a metadata cascade policy attached to any of the parent folders a metadata cascade operation will be kicked off asynchronously.

    We currently have no API to check when this operation has finished.

    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 special names . and .. are not allowed either.

    objectin body

    The destination folder to copy the folder to.

    stringin bodyrequired
    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 invalid.

    • 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.

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

    Response Example

    {
      "id": 12345,
      "etag": 1,
      "type": "folder",
      "sequence_id": 3,
      "name": "Contracts",
      "created_at": "2012-12-12T10:53:43-08:00",
      "modified_at": "2012-12-12T10:53:43-08:00",
      "description": "Legal contracts for the new ACME deal",
      "size": 629644,
      "path_collection": {
        "total_count": 1,
        "entries": [
          {
            "id": 12345,
            "etag": 1,
            "type": "folder",
            "sequence_id": 3,
            "name": "Contracts"
          }
        ]
      },
      "created_by": {
        "id": 11446498,
        "type": "user",
        "name": "Aaron Levie",
        "login": "ceo@example.com"
      },
      "modified_by": {
        "id": 11446498,
        "type": "user",
        "name": "Aaron Levie",
        "login": "ceo@example.com"
      },
      "trashed_at": "2012-12-12T10:53:43-08:00",
      "purged_at": "2012-12-12T10:53:43-08:00",
      "content_created_at": "2012-12-12T10:53:43-08:00",
      "content_modified_at": "2012-12-12T10:53:43-08:00",
      "expires_at": "2012-12-12T10:53:43-08:00",
      "owned_by": {
        "id": 11446498,
        "type": "user",
        "name": "Aaron Levie",
        "login": "ceo@example.com"
      },
      "shared_link": {
        "url": "https://www.box.com/s/vspke7y05sb214wjokpk",
        "download_url": "https://www.box.com/shared/static/rh935iit6ewrmw0unyul.jpeg",
        "vanity_url": "https://acme.app.box.com/v/my_url/",
        "access": "open",
        "effective_access": "company",
        "effective_permission": "can_download",
        "unshared_at": "2018-04-13T13:53:23-07:00",
        "is_password_enabled": true,
        "permissions": {
          "can_download": true,
          "can_preview": true
        },
        "download_count": 3,
        "preview_count": 3
      },
      "folder_upload_email": {
        "access": "open",
        "email": "upload.Contracts.asd7asd@u.box.com"
      },
      "parent": {
        "id": 12345,
        "etag": 1,
        "type": "folder",
        "sequence_id": 3,
        "name": "Contracts"
      },
      "item_status": "active",
      "item_collection": {
        "total_count": 5000,
        "limit": 1000,
        "offset": 2000,
        "order": [
          {
            "by": "type",
            "direction": "ASC"
          }
        ],
        "entries": [
          {
            "id": 12345,
            "etag": 1,
            "type": "file",
            "sequence_id": 3,
            "name": "Contract.pdf"
          }
        ]
      },
      "sync_state": "synced",
      "has_collaborations": true,
      "permissions": {
        "can_delete": true,
        "can_download": true,
        "can_invite_collaborator": true,
        "can_rename": true,
        "can_set_share_access": true,
        "can_share": true,
        "can_upload": true
      },
      "tags": [
        "approved"
      ],
      "can_non_owners_invite": true,
      "is_externally_owned": true,
      "is_collaboration_restricted_to_enterprise": true,
      "allowed_shared_link_access_levels": [
        "open"
      ],
      "allowed_invitee_roles": [
        "open"
      ],
      "watermark_info": {
        "is_watermarked": true
      },
      "can_non_owners_view_collaborators": true
    }