Restore folder

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

Restores a folder that has been moved to the trash.

An optional new parent ID can be provided to restore the folder to in case the original folder has been deleted.

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.

Request

application/json

Path Parameters

stringin pathrequired
0

The unique identifier that represent a folder.

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 of a Box account is always represented by the ID 0.

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
Restored Photos

An optional new name for the folder.

Parentin body

Specifies an optional ID of a folder to restore the folder to when the original folder no longer exists.

Please be aware that this ID will only be used if the original folder no longer exists. Use this ID to provide a fallback location to restore the folder to if the original location has been deleted.

stringin bodyoptional
123

The ID of parent item

Response

application/jsonFolder

Returns a folder object when the folder has been restored.

application/jsonClient Error

Returns an error if the user does not have access to the folder the folder is being restored to, or the user does not have permission to restore folders from the trash.

application/jsonClient Error

Returns an error if the folder is not in the trash.

application/jsonClient Error
  • Returned an error if there is a folder with the same name in the destination folder.

  • operation_blocked_temporary: Returned if either of the destination or source folders is locked due to another move, copy, delete or restore operation in process.

    The operation can be retried at a later point.

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

Request Example

cURL
curl -X GET https://api.box.com/2.0/folders/4353455 \
     -H "Authorization: Bearer <ACCESS_TOKEN>"
.NET
var requestParams = new BoxFolderRequest()
{
    Name = "Name in case of conflict",
    Parent = new BoxRequestEntity()
    {
        // Folder will be placed in this parent folder if original location no longer exists
        Id = "12345" 
    }
};
BoxFolder restoredFolder = await client.FoldersManager.RestoreTrashedFolderAsync(requestParams);
Java
String folderID = "125367";
String newName = "My Documents ORIGINAL";
String newParentID = "98765";

BoxTrash trash = new BoxTrash(api);
// Avoid conflicts at the original location
trash.restoreFolder(folderID, newName, newParentID);
Python
folder_to_restore = client.folder(folder_id='22222')
restored_folder = client.trash().restore_item(folder_to_restore)
print('Folder ID is {0} and name is {1}'.format(restored_folder.id, restored_folder.name))
Node
client.folders.restoreFromTrash(
	'22222',
	{
		// New name in case of conflict
		name: 'New Name',
		// Folder will be placed in this parent folder if the original parent no longer exists
		parent_id: '0'
	})
	.then(restoredFolder => {
		/* trashedFolder -> {
			type: 'folder',
			id: '22222',
			sequence_id: '1',
			etag: '1',
			name: 'Old Files',
			created_at: '2013-05-06T22:37:30-07:00',
			modified_at: '2013-05-06T22:39:08-07:00',
			description: '',
			size: 18482,
			path_collection: 
			{ total_count: 1,
				entries: 
				[ { type: 'folder',
					id: '0',
					sequence_id: null,
					etag: null,
					name: 'All Files' } ] },
			created_by: 
			{ type: 'user',
				id: '33333',
				name: 'Example User',
				login: 'user@example.com' },
			modified_by: 
			{ type: 'user',
				id: '33333',
				name: 'Example User',
				login: 'user@example.com' },
			trashed_at: null,
			purged_at: null,
			content_created_at: '2013-05-06T22:37:30-07:00',
			content_modified_at: '2013-05-06T22:39:08-07:00',
			owned_by: 
			{ type: 'user',
				id: '33333',
				name: 'Example User',
				login: 'user@example.com' },
			shared_link: null,
			folder_upload_email: null,
			parent: 
			{ type: 'folder',
				id: '0',
				sequence_id: null,
				etag: null,
				name: 'All Files' },
			item_status: 'active' }
		*/
	});

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
}