> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # ListDeletedFolders # Package: mediaManager # Namespace: FoldersService # Method link: https://dev.wix.com/docs/api-reference/assets/media/media-manager/folders/list-deleted-folders.md ## Permission Scopes: Read Media Manager: SCOPE.DC-MEDIA.READ-MEDIAMANAGER ## Introduction Retrieves a list of folders in the Media Manager's trash bin. --- ## REST API ### Schema ``` Method: listDeletedFolders Description: Retrieves a list of folders in the Media Manager's trash bin. URL: https://www.wixapis.com/site-media/v1/trash-bin/folders Method: GET Method parameters: param name: paging | type: CursorPaging - name: limit | type: integer | description: Maximum number of items to return in the results. - name: cursor | type: string | description: Pointer to the next or previous page in the list of results. Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request. query param name: parentFolderId | type: parentFolderId | description: GUID of the folder's parent folder. param name: sort | type: Sorting - name: fieldName | type: string | description: Name of the field to sort by. - name: order | type: SortOrder | description: Sort order. - enum: ASC, DESC Return type: ListDeletedFoldersResponse - name: folders | type: array | description: List of folders in the Media Manager's trash bin. - name: id | type: string | description: Folder GUID. Generated when a folder is created in the Media Manager. - name: displayName | type: string | description: Folder name as it appears in the Media Manager. - name: parentFolderId | type: string | description: GUID of the folder's parent folder.
Default: `media-root` folder. - name: createdDate | type: string | description: Date the folder was created. - name: updatedDate | type: string | description: Date the folder was updated. - name: state | type: State | description: State of the folder. - enum: OK, DELETED - name: siteId | type: string | description: Site GUID the folder belongs to. - name: nextCursor | type: PagingMetadataV2 | description: The next cursor if it exists. - name: total | type: integer | description: Total number of items that match the query. Returned if offset paging is used and the `tooManyToCount` flag is not set. - name: cursors | type: Cursors | description: Cursors to navigate through the result pages using `next` and `prev`. Returned if cursor paging is used. - name: next | type: string | description: Cursor string pointing to the next page in the list of results. ``` ### Examples ### List folders in the Media Manager's trash bin This example sorts by `updatedDate` in `DESC` order with a paging limit of 2. ```curl curl -X GET \ 'https://www.wixapis.com/site-media/v1/trash-bin/folders?sort.fieldName=updateDate&sort.order=DESC&paging.limit=2' \ -H 'Authorization: ' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.mediaManager.FoldersService.listDeletedFolders(options) Description: Retrieves a list of folders in the Media Manager's trash bin. Method parameters: param name: options | type: ListDeletedFoldersOptions none - name: parentFolderId | type: string | description: GUID of the folder's parent folder. - name: sort | type: Sorting | description: Field name and order to sort by. One of: * `displayName` * `updatedDate` Default: `updatedDate` in `desc` order. - name: fieldName | type: string | description: Name of the field to sort by. - name: order | type: SortOrder | description: Sort order. - enum: ASC, DESC - name: paging | type: CursorPaging | description: Cursor and paging information. - name: limit | type: integer | description: Maximum number of items to return in the results. - name: cursor | type: string | description: Pointer to the next or previous page in the list of results. Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request. Return type: PROMISE - name: folders | type: array | description: List of folders in the Media Manager's trash bin. - name: _id | type: string | description: Folder GUID. Generated when a folder is created in the Media Manager. - name: displayName | type: string | description: Folder name as it appears in the Media Manager. - name: parentFolderId | type: string | description: GUID of the folder's parent folder.
Default: `media-root` folder. - name: _createdDate | type: Date | description: Date the folder was created. - name: _updatedDate | type: Date | description: Date the folder was updated. - name: state | type: State | description: State of the folder. - enum: OK, DELETED - name: siteId | type: string | description: Site GUID the folder belongs to. - name: nextCursor | type: PagingMetadataV2 | description: The next cursor if it exists. - name: total | type: integer | description: Total number of items that match the query. Returned if offset paging is used and the `tooManyToCount` flag is not set. - name: cursors | type: Cursors | description: Cursors to navigate through the result pages using `next` and `prev`. Returned if cursor paging is used. - name: next | type: string | description: Cursor string pointing to the next page in the list of results. ``` ### Examples ### Bulk restore all folders from the trash bin (with $w) ```javascript /******************************************** * Backend code - restore-folders.web.js/ts * *******************************************/ import { Permissions, webMethod } from '@wix/web-methods'; import { folders } from '@wix/media'; import { auth } from '@wix/essentials'; export const restoreAllFolders = webMethod(Permissions.Anyone, async () => { try { const elevatedListDeletedFolders = auth.elevate(folders.listDeletedFolders); const deletedFolders = await elevatedListDeletedFolders(); const deletedFolderIds = deletedFolders.folders.map((folder) => { return folder._id; }); const elevatedBulkRestoreFoldersFromTrashBin = auth.elevate(folders.bulkRestoreFoldersFromTrashBin); const restoredFolders = await elevatedBulkRestoreFoldersFromTrashBin(deletedFolderIds); return restoredFolders; } catch (error) { console.error(error); } }); /************* * Page code * ************/ import { restoreAllFolders } from 'backend/restore-folders.web'; $w.onReady(async () => { $w('#restoreAll').onClick(async () => { const restoredFolders = await restoreAllFolders(); console.log('Restored all folders:', restoredFolders); $w('#bulkRestoreSuccessMsg').show(); }); }); ``` ### List deleted folders with sort (with elevated permissions) ```javascript import { folders } from '@wix/media'; import { auth } from '@wix/essentials'; /* Sample options value: * { * sort: { * fieldName: 'displayName', * order: 'ASC' * } * } */ export async function listDeletedFolders(options) { try { const elevatedListDeletedFolders = auth.elevate(folders.listDeletedFolders); const deletedFolders = await elevatedListDeletedFolders(options); console.log("Deleted folders, sorted alphabetically by name:", deletedFolders); return deletedFolders; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "folders": [ * { * "_createdDate": "2023-08-21T05:34:03.000Z", * "_id": "302fc049d70c41dea33fa4a27ab481ba", * "_updatedDate": "2023-08-21T05:34:03.000Z", * "displayName": "Videos", * "parentFolderId": "trash-root", * "state": "DELETED" * }, * { * "_createdDate": "2023-08-21T09:32:47.000Z", * "_id": "d4051a6890724365a78678a6208ac37e", * "_updatedDate": "2023-08-21T09:32:47.000Z", * "displayName": "family", * "parentFolderId": "trash-root", * "state": "DELETED" * } * ], * "nextCursor": { * "cursors": { * "next": "" * }, * "hasNext": false * } * } */ ``` ### List deleted folders with sort ```javascript import { folders } from '@wix/media'; /* Sample options value: * { * sort: { * fieldName: 'displayName', * order: 'ASC' * } * } */ export async function listDeletedFolders(options) { try { const deletedFolders = await folders.listDeletedFolders(options); console.log("Deleted folders, sorted alphabetically by name:", deletedFolders); return deletedFolders; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "folders": [ * { * "_createdDate": "2023-08-21T05:34:03.000Z", * "_id": "302fc049d70c41dea33fa4a27ab481ba", * "_updatedDate": "2023-08-21T05:34:03.000Z", * "displayName": "Videos", * "parentFolderId": "trash-root", * "state": "DELETED" * }, * { * "_createdDate": "2023-08-21T09:32:47.000Z", * "_id": "d4051a6890724365a78678a6208ac37e", * "_updatedDate": "2023-08-21T09:32:47.000Z", * "displayName": "family", * "parentFolderId": "trash-root", * "state": "DELETED" * } * ], * "nextCursor": { * "cursors": { * "next": "" * }, * "hasNext": false * } * } */ ``` ### List deleted folders (with elevated permissions) ```javascript import { folders } from '@wix/media'; import { auth } from '@wix/essentials'; const elevatedListDeletedFolders = auth.elevate(folders.listDeletedFolders); async function listDeletedFolders() { try { const deletedFolders = await elevatedListDeletedFolders(); console.log("Deleted Folders:", deletedFolders); return deletedFolders; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "folders": [ * { * "_createdDate": "2023-08-21T09:32:47.000Z", * "_id": "d4051a6890724365a78678a6208ac37e", * "_updatedDate": "2023-08-21T09:32:47.000Z", * "displayName": "family", * "parentFolderId": "trash-root", * "state": "DELETED" * }, * { * "_createdDate": "2023-08-21T05:34:03.000Z", * "_id": "302fc049d70c41dea33fa4a27ab481ba", * "_updatedDate": "2023-08-21T05:34:03.000Z", * "displayName": "Videos", * "parentFolderId": "trash-root", * "state": "DELETED" * } * ], * "nextCursor": { * "cursors": { * "next": "" * }, * "hasNext": false * } * } */ ``` ### List deleted folders ```javascript import { folders } from '@wix/media'; async function listDeletedFolders() { try { const deletedFolders = await folders.listDeletedFolders(); console.log("Deleted Folders:", deletedFolders); return deletedFolders; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "folders": [ * { * "_createdDate": "2023-08-21T09:32:47.000Z", * "_id": "d4051a6890724365a78678a6208ac37e", * "_updatedDate": "2023-08-21T09:32:47.000Z", * "displayName": "family", * "parentFolderId": "trash-root", * "state": "DELETED" * }, * { * "_createdDate": "2023-08-21T05:34:03.000Z", * "_id": "302fc049d70c41dea33fa4a27ab481ba", * "_updatedDate": "2023-08-21T05:34:03.000Z", * "displayName": "Videos", * "parentFolderId": "trash-root", * "state": "DELETED" * } * ], * "nextCursor": { * "cursors": { * "next": "" * }, * "hasNext": false * } * } */ ``` ### listDeletedFolders (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { folders } from '@wix/media'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { folders }, // Include the auth strategy and host as relevant }); async function listDeletedFolders(options) { const response = await myWixClient.folders.listDeletedFolders(options); }; ``` ---