> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# SearchFiles

# Package: mediaManager

# Namespace: FilesService

# Method link: https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/search-files.md

## Permission Scopes:
Read Media Manager: SCOPE.DC-MEDIA.READ-MEDIAMANAGER

## Introduction

Retrieves a list of up to 100 files with the specified filtering, sorting, and cursor paging.

If no parameters are specified, the method returns all files in the `MEDIA_ROOT` folder.

---

## REST API

### Schema

```
 Method: searchFiles
 Description: Retrieves a list of up to 100 files with the specified filtering, sorting, and cursor paging.  If no parameters are specified, the method returns all files in the `MEDIA_ROOT` folder.  ## Defaults  Search Files has the following default setting, which you can override: + Sorted by `updatedDate` in descending order.  ## Filters  When using filters for dates, you must use [UTC time](https://en.wikipedia.org/wiki/Coordinated_Universal_Time).  ## See also  To learn about working with *Search* methods, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md) and   [Sorting and Paging](https://dev.wix.com/docs/rest/articles/get-started/sorting-and-paging.md).
 URL: https://www.wixapis.com/site-media/v1/files/search
 Method: POST
 Method parameters:
   param name: mediaTypes | type: array<mediaTypes> | description: File media type.  | validation: maxItems 30
                 - enum:
                 -     UNKNOWN: Unknown media type.
                 -     IMAGE: Image file, such as JPEG or PNG.
                 -     VIDEO: Video file.
                 -     AUDIO: Audio file.
                 -     DOCUMENT: Document file, such as PDF.
                 -     VECTOR: Vector image file, such as SVG.
                 -     ARCHIVE: Archive file, such as ZIP.
                 -     MODEL3D: 3D model file.
                 -     OTHER: Any other file type.
   param name: paging | type: CursorPaging    
        - name: limit | type: integer | description: Maximum number of items to return in the results.  | validation: minimum 0, maximum 100, format int32
        - 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.  | validation: maxLength 16000
   param name: private | type: private | description: Whether to return only private or only public files. + `true`: Returns only private files. + `false`: Returns only public files. + `undefined`: Returns public and private files.  Learn more [about private files](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/private-files.md).  
   param name: rootFolder | type: RootFolder    
      - enum:
           MEDIA_ROOT - Contains all files and folders in the Media Manager's **Site Files** tab in the UI.
           TRASH_ROOT - Contains all files and folders in the Media Manager's **Trash** tab in the UI.
           VISITOR_UPLOADS_ROOT - Contains all files and folders created by site visitors or members.
   param name: search | type: search | description: Free text to match in searchable fields.  For example, search for specific values in a file's `displayName`, `mimeType`, or `label`.  | validation: maxLength 200
   param name: sort | type: Sorting    
        - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
        - name: order | type: SortOrder | description: Sort order.  
             - enum: ASC, DESC
        - name: origin | type: AddressLocation | description: Origin point for geo-distance sorting on a GEO field results are ordered by distance from this point (ASC = nearest first, DESC = farthest first).  
           - name: latitude | type: number | description: Address latitude.  | validation: format double
           - name: longitude | type: number | description: Address longitude.  | validation: format double
 Return type: SearchFilesResponse
  - name: files | type: array<FileDescriptor> | description: Retrieved files that match the search criteria specified in the request.  Each file includes all standard file information.  | validation: maxItems 200
     - name: id | type: string | description: File GUID. Generated when a file is uploaded to the Media Manager.  | read-only: true | validation: maxLength 1000
     - name: displayName | type: string | description: File name as it appears in the Media Manager.  | validation: maxLength 255
     - name: url | type: string | description: Static URL of the file.  | read-only: true | validation: format WEB_URL
     - name: parentFolderId | type: string | description: GUID of the file's parent folder.  | validation: maxLength 100
     - name: hash | type: string | description: File hash.  | read-only: true | validation: maxLength 100
     - name: sizeInBytes | type: string | description: Size of the uploaded file in bytes.  | read-only: true | validation: format DECIMAL_VALUE, decimalValue {"maxScale":0}
     - name: private | type: boolean | description: Whether the file is public or private. Learn more about [private files](https://dev.wix.com/docs/rest/assets/media/media-manager/files/private-files.md).  | read-only: true 
     - name: mediaType | type: MediaType | description: Media file type.  | read-only: true 
         - enum:
         -     UNKNOWN: Unknown media type.
         -     IMAGE: Image file, such as JPEG or PNG.
         -     VIDEO: Video file.
         -     AUDIO: Audio file.
         -     DOCUMENT: Document file, such as PDF.
         -     VECTOR: Vector image file, such as SVG.
         -     ARCHIVE: Archive file, such as ZIP.
         -     MODEL3D: 3D model file.
         -     OTHER: Any other file type.
     - name: media | type: FileMedia | description: Media-type-specific metadata, such as an image's dimensions or a video's available resolutions. The relevant property is populated according to the file's `mediaType`.  | read-only: true 
        - ONE-OF: 
           - name: image | type: ImageMedia | description: Information about the image.  
              - name: image | type: Image | description: Image data.  
                 - name: id | type: string | description: WixMedia image GUID.  
                 - name: url | type: string | description: Image URL.  
                 - name: height | type: integer | description: Original image height.  | read-only: true 
                 - name: width | type: integer | description: Original image width.  | read-only: true 
                 - name: altText | type: string | description: Image alt text.  
                 - name: filename | type: string | description: Image filename.  | read-only: true 
              - name: colors | type: Colors | description: Image colors.  
                 - name: prominent | type: Color | description: Main color of the image.  
                    - name: hex | type: string | description: HEX color.  | validation: format COLOR_HEX
                    - name: rgb | type: ColorRGB | description: RGB color.  
                       - name: r | type: integer | description: Red channel.  | validation: minimum 0, maximum 255, format int32
                       - name: g | type: integer | description: Green channel.  | validation: minimum 0, maximum 255, format int32
                       - name: b | type: integer | description: Blue channel.  | validation: minimum 0, maximum 255, format int32
                 - name: palette | type: array<Color> | description: Color palette of the image.  | validation: maxItems 100
              - name: faces | type: array<FaceRecognition> | description: Information about faces in the image. Use to crop images without cutting out faces.  | validation: maxItems 100
                 - name: confidence | type: number | description: The accuracy percentage of the face recognition. The likelihood that a face is detected.  
                 - name: x | type: integer | description: Top left x pixel coordinate of the face.  
                 - name: y | type: integer | description: Top left y pixel coordinate of the face.  
                 - name: height | type: integer | description: Face pixel height.  
                 - name: width | type: integer | description: Face pixel width.  
              - name: previewImage | type: Image | description: Information about the image preview. You can use this to display a preview for private images.  
              - name: caption | type: string | description: Optional, An AI generated description of the image  | read-only: true | validation: maxLength 300
           - name: video | type: VideoV2 | description: Information about the video.  
              - name: id | type: string | description: WixMedia GUID.  
              - name: resolutions | type: array<VideoResolution> | description: Available resolutions for the video, starting with the optimal resolution.  | read-only: true | validation: maxItems 100
                 - name: url | type: string | description: Video URL.  
                 - name: height | type: integer | description: Video height.  
                 - name: width | type: integer | description: Video width.  
                 - name: format | type: string | description: Video format Possible values: ['144p.mp4' '144p.webm' '240p.mp4' '240p.webm' '360p.mp4' '360p.webm' '480p.mp4' '480p.webm' '720p.mp4' '720p.webm' '1080p.mp4' '1080p.webm', 'hls' ]  
              - name: filename | type: string | description: Video filename.  | read-only: true 
           - name: audio | type: AudioV2 | description: Information about the audio.  
              - name: id | type: string | description: WixMedia GUID.  | validation: maxLength 200
              - name: assets | type: array<Audio> | description: Audio formats available for this file.  | validation: maxItems 100
                 - name: id | type: string | description: WixMedia GUID.  
                 - name: url | type: string | description: Audio URL.  
                 - name: filename | type: string | description: Audio filename.  | read-only: true 
              - name: bitrate | type: integer | description: Audio bitrate.  | read-only: true | validation: minimum 0, format int32
              - name: format | type: string | description: Audio format.  | read-only: true | validation: maxLength 100
              - name: duration | type: integer | description: Audio duration in seconds.  | read-only: true | validation: minimum 0, format int32
              - name: sizeInBytes | type: string | description: Audio size in bytes.  | read-only: true | validation: format DECIMAL_VALUE, decimalValue {"maxScale":0}
           - name: document | type: Document | description: Information about the document.  
              - name: id | type: string | description: WixMedia GUID.  
              - name: url | type: string | description: Document URL.  
              - name: filename | type: string | description: Document filename.  
           - name: vector | type: ImageMedia | description: Information about the vector.  
           - name: archive | type: Archive | description: Information about the archive.  
              - name: id | type: string | description: WixMedia GUID.  
              - name: url | type: string | description: Archive URL.  
              - name: urlExpirationDate | type: string | description: Archive URL expiration date (when relevant).  | read-only: true | validation: format date-time
              - name: sizeInBytes | type: string | description: Archive size in bytes.  | validation: format DECIMAL_VALUE
              - name: filename | type: string | description: Archive filename.  
           - name: model3d | type: Model3D | description: Information about the 3D Model.  
              - name: id | type: string | description: WixMedia 3D GUID.  
              - name: url | type: string | description: 3D URL.  
              - name: thumbnail | type: Image | description: 3D thumbnail Image  
              - name: altText | type: string | description: 3D alt text.  
              - name: urlExpirationDate | type: string | description: 3D URL expiration date (when relevant).  | read-only: true | validation: format date-time
              - name: filename | type: string | description: 3D filename.  | read-only: true 
              - name: sizeInBytes | type: string | description: 3D size in bytes.  | read-only: true | validation: format DECIMAL_VALUE
     - name: operationStatus | type: OperationStatus | description: Status of the file that was uploaded.  | read-only: true 
         - enum:
         -     FAILED: The file failed to upload, for example, during media post processing.
         -     READY: The file uploaded, finished all processing, and is ready for use.
         -     PENDING: The file is processing and the URLs are not yet available. This response is returned when importing a file.
     - name: sourceUrl | type: string | description: URL where the file was uploaded from.  | read-only: true | validation: format WEB_URL
     - name: thumbnailUrl | type: string | description: URL of the file's thumbnail.  | read-only: true | validation: format WEB_URL
     - name: labels | type: array<string> | description: Labels assigned to media files that describe and categorize them. Provided by the Wix user, or generated by [Google Vision API](https://cloud.google.com/vision/docs/drag-and-drop) for images.  | validation: maxItems 100, maxLength 200
     - name: createdDate | type: string | description: Date and time the file was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the file was updated.  | read-only: true | validation: format date-time
     - name: siteId | type: string | description: The Wix site GUID where the media file is stored.  | read-only: true | validation: maxLength 100
     - name: state | type: State | description: State of the file.  | read-only: true 
         - enum:
         -     OK: File is ready for consumption
         -     DELETED: Deleted file
  - 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.  | validation: format int32
     - 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.  | validation: maxLength 16000

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_SORT_VALUE | Description: Sort value isn't supported.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_MEDIA_TYPE | Description: Media type isn't supported for filtering.


```

### Examples

### Search files
```curl
curl -X POST \
  'https://www.wixapis.com/site-media/v1/files/search' \
  -H 'Authorization: <AUTH>'
  --data-binary '{
    "search": "building",
    "rootFolder": "MEDIA_ROOT",
    "sort": {
      "fieldName": "displayName",
      "order": "DESC"
    }
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.media.files.searchFiles(options)
 Description: Retrieves a list of up to 100 files with the specified filtering, sorting, and cursor paging.  If no parameters are specified, the method returns all files in the `MEDIA_ROOT` folder.  ## Defaults  Search Files has the following default setting, which you can override: + Sorted by `updatedDate` in descending order.  ## Filters  When using filters for dates, you must use [UTC time](https://en.wikipedia.org/wiki/Coordinated_Universal_Time).  ## See also  To learn about working with *Search* methods, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md) and   [Sorting and Paging](https://dev.wix.com/docs/rest/articles/get-started/sorting-and-paging.md).
 Method parameters:
   param name: options | type: SearchFilesOptions  none  
        - name: search | type: string | description: Free text to match in searchable fields.  For example, search for specific values in a file's `displayName`, `mimeType`, or `label`.  | validation: maxLength 200
        - name: rootFolder | type: RootFolder | description: The root folder in the media manager to search in. For more information, see Root Folders in [Terminology](https://dev.wix.com/docs/rest/assets/media/media-manager/introduction.md#terminology).  Default: `MEDIA_ROOT`.  
             - enum:
             -     MEDIA_ROOT: Contains all files and folders in the Media Manager's **Site Files** tab in the UI.
             -     TRASH_ROOT: Contains all files and folders in the Media Manager's **Trash** tab in the UI.
             -     VISITOR_UPLOADS_ROOT: Contains all files and folders created by site visitors or members.
        - name: mediaTypes | type: array<MediaType> | description: File media type.  | validation: maxItems 30
             - enum:
             -     UNKNOWN: Unknown media type.
             -     IMAGE: Image file, such as JPEG or PNG.
             -     VIDEO: Video file.
             -     AUDIO: Audio file.
             -     DOCUMENT: Document file, such as PDF.
             -     VECTOR: Vector image file, such as SVG.
             -     ARCHIVE: Archive file, such as ZIP.
             -     MODEL3D: 3D model file.
             -     OTHER: Any other file type.
        - name: private | type: boolean | description: Whether to return only private or only public files. + `true`: Returns only private files. + `false`: Returns only public files. + `undefined`: Returns public and private files.  Learn more [about private files](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/private-files.md).  
        - name: sort | type: Sorting | description: Field name and order to sort by.  One of: `displayName` `updatedDate` `sizeInBytes`  Default: `updatedDate` in `desc` order.  
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
           - name: origin | type: AddressLocation | description: Origin point for geo-distance sorting on a GEO field results are ordered by distance from this point (ASC = nearest first, DESC = farthest first).  
              - name: latitude | type: number | description: Address latitude.  
              - name: longitude | type: number | description: Address longitude.  
        - name: paging | type: CursorPaging | description: Cursor and paging information.  
           - name: limit | type: integer | description: Maximum number of items to return in the results.  | validation: minimum 0, maximum 100, format int32
           - 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.  | validation: maxLength 16000
 Return type: PROMISE<SearchFilesResponse>
  - name: files | type: array<FileDescriptor> | description: Retrieved files that match the search criteria specified in the request.  Each file includes all standard file information.  | validation: maxItems 200
     - name: _id | type: string | description: File GUID. Generated when a file is uploaded to the Media Manager.  | read-only: true | validation: maxLength 1000
     - name: displayName | type: string | description: File name as it appears in the Media Manager.  | validation: maxLength 255
     - name: url | type: string | description: Static URL of the file.  | read-only: true | validation: format WEB_URL
     - name: parentFolderId | type: string | description: GUID of the file's parent folder.  | validation: maxLength 100
     - name: hash | type: string | description: File hash.  | read-only: true | validation: maxLength 100
     - name: sizeInBytes | type: string | description: Size of the uploaded file in bytes.  | read-only: true | validation: format DECIMAL_VALUE, decimalValue {"maxScale":0}
     - name: private | type: boolean | description: Whether the file is public or private. Learn more about [private files](https://dev.wix.com/docs/rest/assets/media/media-manager/files/private-files.md).  | read-only: true 
     - name: mediaType | type: MediaType | description: Media file type.  | read-only: true 
         - enum:
         -     UNKNOWN: Unknown media type.
         -     IMAGE: Image file, such as JPEG or PNG.
         -     VIDEO: Video file.
         -     AUDIO: Audio file.
         -     DOCUMENT: Document file, such as PDF.
         -     VECTOR: Vector image file, such as SVG.
         -     ARCHIVE: Archive file, such as ZIP.
         -     MODEL3D: 3D model file.
         -     OTHER: Any other file type.
     - name: media | type: FileMedia | description: Media-type-specific metadata, such as an image's dimensions or a video's available resolutions. The relevant property is populated according to the file's `mediaType`.  | read-only: true 
        - ONE-OF: 
           - name: image | type: ImageMedia | description: Information about the image.  
              - name: image | type: string | description: Image data.  
              - name: colors | type: Colors | description: Image colors.  
                 - name: prominent | type: Color | description: Main color of the image.  
                    - name: hex | type: string | description: HEX color.  | validation: format COLOR_HEX
                    - name: rgb | type: ColorRGB | description: RGB color.  
                       - name: r | type: integer | description: Red channel.  | validation: minimum 0, maximum 255, format int32
                       - name: g | type: integer | description: Green channel.  | validation: minimum 0, maximum 255, format int32
                       - name: b | type: integer | description: Blue channel.  | validation: minimum 0, maximum 255, format int32
                 - name: palette | type: array<Color> | description: Color palette of the image.  | validation: maxItems 100
              - name: faces | type: array<FaceRecognition> | description: Information about faces in the image. Use to crop images without cutting out faces.  | validation: maxItems 100
                 - name: confidence | type: number | description: The accuracy percentage of the face recognition. The likelihood that a face is detected.  
                 - name: x | type: integer | description: Top left x pixel coordinate of the face.  
                 - name: y | type: integer | description: Top left y pixel coordinate of the face.  
                 - name: height | type: integer | description: Face pixel height.  
                 - name: width | type: integer | description: Face pixel width.  
              - name: previewImage | type: string | description: Information about the image preview. You can use this to display a preview for private images.  
              - name: caption | type: string | description: Optional, An AI generated description of the image  | read-only: true | validation: maxLength 300
           - name: video | type: string | description: Information about the video.  
           - name: audio | type: AudioV2 | description: Information about the audio.  
              - name: _id | type: string | description: WixMedia GUID.  | validation: maxLength 200
              - name: assets | type: array<string> | description: Audio formats available for this file.  | validation: maxItems 100
              - name: bitrate | type: integer | description: Audio bitrate.  | read-only: true | validation: minimum 0, format int32
              - name: format | type: string | description: Audio format.  | read-only: true | validation: maxLength 100
              - name: duration | type: integer | description: Audio duration in seconds.  | read-only: true | validation: minimum 0, format int32
              - name: sizeInBytes | type: string | description: Audio size in bytes.  | read-only: true | validation: format DECIMAL_VALUE, decimalValue {"maxScale":0}
           - name: document | type: string | description: Information about the document.  
           - name: vector | type: ImageMedia | description: Information about the vector.  
           - name: archive | type: Archive | description: Information about the archive.  
              - name: _id | type: string | description: WixMedia GUID.  
              - name: url | type: string | description: Archive URL.  
              - name: urlExpirationDate | type: Date | description: Archive URL expiration date (when relevant).  | read-only: true 
              - name: sizeInBytes | type: string | description: Archive size in bytes.  | validation: format DECIMAL_VALUE
              - name: filename | type: string | description: Archive filename.  
           - name: model3d | type: Model3D | description: Information about the 3D Model.  
              - name: _id | type: string | description: WixMedia 3D GUID.  
              - name: url | type: string | description: 3D URL.  
              - name: thumbnail | type: string | description: 3D thumbnail Image  
              - name: altText | type: string | description: 3D alt text.  
              - name: urlExpirationDate | type: Date | description: 3D URL expiration date (when relevant).  | read-only: true 
              - name: filename | type: string | description: 3D filename.  | read-only: true 
              - name: sizeInBytes | type: string | description: 3D size in bytes.  | read-only: true | validation: format DECIMAL_VALUE
     - name: operationStatus | type: OperationStatus | description: Status of the file that was uploaded.  | read-only: true 
         - enum:
         -     FAILED: The file failed to upload, for example, during media post processing.
         -     READY: The file uploaded, finished all processing, and is ready for use.
         -     PENDING: The file is processing and the URLs are not yet available. This response is returned when importing a file.
     - name: sourceUrl | type: string | description: URL where the file was uploaded from.  | read-only: true | validation: format WEB_URL
     - name: thumbnailUrl | type: string | description: URL of the file's thumbnail.  | read-only: true | validation: format WEB_URL
     - name: labels | type: array<string> | description: Labels assigned to media files that describe and categorize them. Provided by the Wix user, or generated by [Google Vision API](https://cloud.google.com/vision/docs/drag-and-drop) for images.  | validation: maxItems 100, maxLength 200
     - name: _createdDate | type: Date | description: Date and time the file was created.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date and time the file was updated.  | read-only: true 
     - name: siteId | type: string | description: The Wix site GUID where the media file is stored.  | read-only: true | validation: maxLength 100
     - name: state | type: State | description: State of the file.  | read-only: true 
         - enum:
         -     OK: File is ready for consumption
         -     DELETED: Deleted file
  - 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.  | validation: format int32
     - 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.  | validation: maxLength 16000

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_SORT_VALUE | Description: Sort value isn't supported.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_MEDIA_TYPE | Description: Media type isn't supported for filtering.


```

### Examples

### Bulk delete all files found in a chosen folder (with $w)
This code shows a page where the visitor chooses a folder by typing the folder's name in an input box, and then all the files in the chosen folder are deleted. Only visitors with permission to manage the site's media would have access to this page.

```javascript
/**********************************************
 * Backend code - bulk-delete-files.web.js/ts *
 *********************************************/

import { Permissions, webMethod } from '@wix/web-methods';
import { files } from '@wix/media';
import { auth } from '@wix/essentials';

export const deleteFiles = webMethod(Permissions.Anyone, async (fileIds, options) => {
  try {
    const elevatedBulkDeleteFiles = auth.elevate(files.bulkDeleteFiles);
    await elevatedBulkDeleteFiles(fileIds, options);

    console.log(`Permanently deleted files with ids: ${fileIds.toString()}.`);
    return true;
  } catch (error) {
    console.error(error);
  }
});

export const searchFileIds = webMethod(Permissions.Anyone, async (parentFolderId) => {
  try {
    const options = { parentFolder: parentFolderId };
    const elevatedSearchFiles = auth.elevate(files.searchFiles);
    const returnedFiles = await elevatedSearchFiles(options);

    const fileIds = returnedFiles.files.map((file) => {
      return file._id;
    });

    return fileIds;
  } catch (error) {
    console.error(error);
  }
});

/*************
 * Page code *
 ************/

import { deleteFiles, searchFileIds } from 'backend/bulk-delete-files.web';

$w.onReady(() => {
  $w('#delete').onClick(async () => {
    const isDeletePermanently = $w('#deletePermanently').checked;
    const options = { permanent: isDeletePermanently };

    const parentFolder = $w('#parentFolder').value;
    const fileIds = await searchFileIds(parentFolder);

    await deleteFiles(fileIds, options);
    $w('#successMessage').show();
  });
});

```

### Search files with options (with elevated permissions)
When no `rootFolder` is specified in the options parameter, the search returns results from the 'MEDIA_ROOT' folder.

```javascript
import { files } from '@wix/media';
import { auth } from '@wix/essentials';

/* Sample searchOptions value:
 * {
 *   mediaTypes: ['IMAGE', 'ARCHIVE'],
 *   search: 'river'
 * }
 */

async function mySearchFilesFunction(searchOptions) {
  try {
    const elevatedSearchFiles = auth.elevate(files.searchFiles);
    const searchFiles = await elevatedSearchFiles(searchOptions);

    console.log('Search files result:', searchFiles);
    return searchFiles;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to: 
 * {
 *   "files": [
 *     {
 *       "_createdDate": "2023-07-16T08:54:05.000Z",
 *       "_id": "w8ide0_j18vyi43l4adwd81tpioxumkojv3dg78~mv2.jpg",
 *       "_updatedDate": "2023-07-19T08:43:58.000Z",
 *       "displayName": "river",
 *       "hash": "xa8k1btltmtn0nimi7a2diwdxd4aujku",
 *       "internalTags": [
 *         "_fileOrigin_uploaded"
 *       ],
 *       "labels": [
 *         "mountain stream",
 *         "fresh water",
 *         "river bank",
 *         "natural scenery"
 *       ],
 *       "media": {
 *         "image": {
 *           "colors": {
 *             "palette": [
 *               {
 *                 "rgb": {
 *                   "b": 41,
 *                   "g": 41,
 *                   "r": 24
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 135,
 *                   "g": 105,
 *                   "r": 62
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 195,
 *                   "g": 154,
 *                   "r": 105
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 230,
 *                   "g": 190,
 *                   "r": 141
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 96,
 *                   "g": 77,
 *                   "r": 44
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 144,
 *                   "g": 135,
 *                   "r": 99
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 64,
 *                   "g": 106,
 *                   "r": 64
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 178,
 *                   "g": 131,
 *                   "r": 80
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 247,
 *                   "g": 230,
 *                   "r": 185
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 75,
 *                   "g": 145,
 *                   "r": 97
 *                 }
 *               }
 *             ],
 *             "prominent": {
 *               "rgb": {
 *                 "b": 41,
 *                 "g": 41,
 *                 "r": 24
 *               }
 *             }
 *           },
 *           "faces": [],
 *           "image": "wix:image://v1/w8ide0_j18vyi43l4adwd81tpioxumkojv3dg78~mv2.jpg/river#originWidth=5760&originHeight=3840"
 *         }
 *       },
 *       "mediaType": "IMAGE",
 *       "operationStatus": "READY",
 *       "parentFolderId": "media-root",
 *       "private": false,
 *       "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
 *       "sizeInBytes": "3677628",
 *       "state": "OK",
 *       "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_j18vyi43l4adwd81tpioxumkojv3dg78~mv2.jpg",
 *       "url": "https://static.wixstatic.com/media/w8ide0_j18vyi43l4adwd81tpioxumkojv3dg78~mv2.jpg"
 *     },
 *     {
 *       "_createdDate": "2023-07-16T08:56:10.000Z",
 *       "_id": "w8ide0_r047t3x8bm46vlx5n1aeha1bdd7g4u1y.zip",
 *       "_updatedDate": "2023-07-20T07:16:55.000Z",
 *       "displayName": "riverpics",
 *       "hash": "3vx3d37vf3j2ttxp61ax7wlt0iox58nh",
 *       "internalTags": [
 *         "_fileOrigin_uploaded"
 *       ],
 *       "labels": [],
 *       "media": {
 *         "archive": {
 *           "_id": "w8ide0_r047t3x8bm46vlx5n1aeha1bdd7g4u1y.zip",
 *           "filename": "riverpics",
 *           "sizeInBytes": "49546083",
 *           "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/archives/w8ide0_r047t3x8bm46vlx5n1aeha1bdd7g4u1y.zip"
 *         }
 *       },
 *       "mediaType": "ARCHIVE",
 *       "operationStatus": "READY",
 *       "parentFolderId": "media-root",
 *       "private": false,
 *       "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
 *       "sizeInBytes": "49546083",
 *       "state": "OK",
 *       "thumbnailUrl": "https://static.wixstatic.com/media/48c4fbc47d7298cd4406936294b4c532.png",
 *       "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/archives/w8ide0_r047t3x8bm46vlx5n1aeha1bdd7g4u1y.zip"
 *     }
 *   ],
 *   "nextCursor": {
 *     "cursors": {
 *       "next": ""
 *     },
 *     "hasNext": false
 *   }
 * }
 */
```

### Search files with options
When no `rootFolder` is specified in the options parameter, the search returns results from the 'MEDIA_ROOT' folder.

```javascript
import { files } from '@wix/media';

/* Sample searchOptions value:
 * {
 *   mediaTypes: ['IMAGE', 'ARCHIVE'],
 *   search: 'river'
 * }
 */

async function mySearchFilesFunction(searchOptions) {
  try {
    const searchFiles = await files.searchFiles(searchOptions);

    console.log('Search files result:', searchFiles);
    return searchFiles;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to: 
 * {
 *   "files": [
 *     {
 *       "_createdDate": "2023-07-16T08:54:05.000Z",
 *       "_id": "w8ide0_j18vyi43l4adwd81tpioxumkojv3dg78~mv2.jpg",
 *       "_updatedDate": "2023-07-19T08:43:58.000Z",
 *       "displayName": "river",
 *       "hash": "xa8k1btltmtn0nimi7a2diwdxd4aujku",
 *       "internalTags": [
 *         "_fileOrigin_uploaded"
 *       ],
 *       "labels": [
 *         "mountain stream",
 *         "fresh water",
 *         "river bank",
 *         "natural scenery"
 *       ],
 *       "media": {
 *         "image": {
 *           "colors": {
 *             "palette": [
 *               {
 *                 "rgb": {
 *                   "b": 41,
 *                   "g": 41,
 *                   "r": 24
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 135,
 *                   "g": 105,
 *                   "r": 62
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 195,
 *                   "g": 154,
 *                   "r": 105
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 230,
 *                   "g": 190,
 *                   "r": 141
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 96,
 *                   "g": 77,
 *                   "r": 44
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 144,
 *                   "g": 135,
 *                   "r": 99
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 64,
 *                   "g": 106,
 *                   "r": 64
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 178,
 *                   "g": 131,
 *                   "r": 80
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 247,
 *                   "g": 230,
 *                   "r": 185
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 75,
 *                   "g": 145,
 *                   "r": 97
 *                 }
 *               }
 *             ],
 *             "prominent": {
 *               "rgb": {
 *                 "b": 41,
 *                 "g": 41,
 *                 "r": 24
 *               }
 *             }
 *           },
 *           "faces": [],
 *           "image": "wix:image://v1/w8ide0_j18vyi43l4adwd81tpioxumkojv3dg78~mv2.jpg/river#originWidth=5760&originHeight=3840"
 *         }
 *       },
 *       "mediaType": "IMAGE",
 *       "operationStatus": "READY",
 *       "parentFolderId": "media-root",
 *       "private": false,
 *       "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
 *       "sizeInBytes": "3677628",
 *       "state": "OK",
 *       "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_j18vyi43l4adwd81tpioxumkojv3dg78~mv2.jpg",
 *       "url": "https://static.wixstatic.com/media/w8ide0_j18vyi43l4adwd81tpioxumkojv3dg78~mv2.jpg"
 *     },
 *     {
 *       "_createdDate": "2023-07-16T08:56:10.000Z",
 *       "_id": "w8ide0_r047t3x8bm46vlx5n1aeha1bdd7g4u1y.zip",
 *       "_updatedDate": "2023-07-20T07:16:55.000Z",
 *       "displayName": "riverpics",
 *       "hash": "3vx3d37vf3j2ttxp61ax7wlt0iox58nh",
 *       "internalTags": [
 *         "_fileOrigin_uploaded"
 *       ],
 *       "labels": [],
 *       "media": {
 *         "archive": {
 *           "_id": "w8ide0_r047t3x8bm46vlx5n1aeha1bdd7g4u1y.zip",
 *           "filename": "riverpics",
 *           "sizeInBytes": "49546083",
 *           "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/archives/w8ide0_r047t3x8bm46vlx5n1aeha1bdd7g4u1y.zip"
 *         }
 *       },
 *       "mediaType": "ARCHIVE",
 *       "operationStatus": "READY",
 *       "parentFolderId": "media-root",
 *       "private": false,
 *       "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
 *       "sizeInBytes": "49546083",
 *       "state": "OK",
 *       "thumbnailUrl": "https://static.wixstatic.com/media/48c4fbc47d7298cd4406936294b4c532.png",
 *       "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/archives/w8ide0_r047t3x8bm46vlx5n1aeha1bdd7g4u1y.zip"
 *     }
 *   ],
 *   "nextCursor": {
 *     "cursors": {
 *       "next": ""
 *     },
 *     "hasNext": false
 *   }
 * }
 */
```

### Search files (with elevated permissions)
```javascript
import { files } from '@wix/media';
import { auth } from '@wix/essentials';

const elevatedSearchFiles = auth.elevate(files.searchFiles);

async function mySearchFilesFunction() {
  try {
    const rootFiles = await elevatedSearchFiles();

    console.log('Files in MEDIA_ROOT', rootFiles);
    return rootFiles;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "files": [
 *     {
 *       "_createdDate": "2023-07-16T08:54:05.000Z",
 *       "_id": "w8ide0_ouulk5w0mdr9omjkwsfyn71g4mb1olcf~mv2.jpg",
 *       "_updatedDate": "2023-07-16T08:54:05.000Z",
 *       "displayName": "image2.jpg",
 *       "hash": "800fae3e0cb7908518a391c25864436c",
 *       "internalTags": [
 *         "_fileOrigin_uploaded"
 *       ],
 *       "labels": [
 *         "label1",
 *         "label2",
 *         "label3",
 *         "label4"
 *       ],
 *       "media": {
 *         "image": {
 *           "colors": {
 *             "palette": [
 *               {
 *                 "rgb": {
 *                   "b": 47,
 *                   "g": 36,
 *                   "r": 31
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 155,
 *                   "g": 153,
 *                   "r": 195
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 141,
 *                   "g": 123,
 *                   "r": 138
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 177,
 *                   "g": 161,
 *                   "r": 190
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 179,
 *                   "g": 178,
 *                   "r": 217
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 160,
 *                   "g": 176,
 *                   "r": 229
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 176,
 *                   "g": 151,
 *                   "r": 162
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 93,
 *                   "g": 78,
 *                   "r": 71
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 45,
 *                   "g": 63,
 *                   "r": 107
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 104,
 *                   "g": 88,
 *                   "r": 82
 *                 }
 *               }
 *             ],
 *             "prominent": {
 *               "rgb": {
 *                 "b": 26,
 *                 "g": 36,
 *                 "r": 39
 *               }
 *             }
 *           },
 *           "faces": [],
 *           "image": "wix:image://v1/w8ide0_ouulk5w0mdr9omjkwsfyn71g4mb1olcf~mv2.jpg/image2.jpg#originWidth=5833&originHeight=3894"
 *         }
 *       },
 *       "mediaType": "IMAGE",
 *       "operationStatus": "READY",
 *       "parentFolderId": "media-root",
 *       "private": false,
 *       "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
 *       "sizeInBytes": "3013886",
 *       "state": "OK",
 *       "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_ouulk5w0mdr9omjkwsfyn71g4mb1olcf~mv2.jpg",
 *       "url": "https://static.wixstatic.com/media/w8ide0_ouulk5w0mdr9omjkwsfyn71g4mb1olcf~mv2.jpg"
 *     },
 *     {
 *       "_createdDate": "2023-07-16T08:56:07.000Z",
 *       "_id": "w8ide0_suuti24j47vesffndm8hkd651u72vp3f~mv2.jpg",
 *       "_updatedDate": "2023-07-16T08:56:07.000Z",
 *       "displayName": "image1.jpg",
 *       "hash": "fef0ylitxcnlyzxf0nahu8rh3k0i5t85",
 *       "internalTags": [
 *         "_fileOrigin_uploaded"
 *       ],
 *       "labels": [
 *         "label1"
 *       ],
 *       "media": {
 *         "image": {
 *           "colors": {
 *             "palette": [
 *               {
 *                 "rgb": {
 *                   "b": 26,
 *                   "g": 36,
 *                   "r": 39
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 135,
 *                   "g": 125,
 *                   "r": 119
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 208,
 *                   "g": 209,
 *                   "r": 208
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 40,
 *                   "g": 108,
 *                   "r": 130
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 133,
 *                   "g": 101,
 *                   "r": 75
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 36,
 *                   "g": 78,
 *                   "r": 94
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 178,
 *                   "g": 161,
 *                   "r": 148
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 192,
 *                   "g": 177,
 *                   "r": 163
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 159,
 *                   "g": 184,
 *                   "r": 208
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 137,
 *                   "g": 159,
 *                   "r": 183
 *                 }
 *               }
 *             ],
 *             "prominent": {
 *               "rgb": {
 *                 "b": 26,
 *                 "g": 36,
 *                 "r": 39
 *               }
 *             }
 *           },
 *           "faces": [],
 *           "image": "wix:image://v1/w8ide0_suuti24j47vesffndm8hkd651u72vp3f~mv2.jpg/image1.jpg#originWidth=5616&originHeight=3744"
 *         }
 *       },
 *       "mediaType": "IMAGE",
 *       "operationStatus": "READY",
 *       "parentFolderId": "media-root",
 *       "private": false,
 *       "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
 *       "sizeInBytes": "6312959",
 *       "state": "OK",
 *       "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_suuti24j47vesffndm8hkd651u72vp3f~mv2.jpg",
 *       "url": "https://static.wixstatic.com/media/w8ide0_suuti24j47vesffndm8hkd651u72vp3f~mv2.jpg"
 *     },
 *     {
 *       "_createdDate": "2023-07-16T08:56:10.000Z",
 *       "_id": "w8ide0_9yvsg5vv40flojo0120h0rz6ki4g0tur.zip",
 *       "_updatedDate": "2023-07-16T08:56:10.000Z",
 *       "displayName": "file1.zip",
 *       "hash": "urm9iak1w39pk381ucb9kqjphya8loro",
 *       "internalTags": [
 *         "_fileOrigin_uploaded"
 *       ],
 *       "labels": [],
 *       "media": {
 *         "archive": {
 *           "_id": "w8ide0_9yvsg5vv40flojo0120h0rz6ki4g0tur.zip",
 *           "filename": "file1.zip",
 *           "sizeInBytes": "49546083",
 *           "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/archives/w8ide0_9yvsg5vv40flojo0120h0rz6ki4g0tur.zip"
 *         }
 *       },
 *       "mediaType": "ARCHIVE",
 *       "operationStatus": "READY",
 *       "parentFolderId": "media-root",
 *       "private": false,
 *       "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
 *       "sizeInBytes": "49546083",
 *       "state": "OK",
 *       "thumbnailUrl": "https://static.wixstatic.com/media/48c4fbc47d7298cd4406936294b4c532.png",
 *       "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/archives/w8ide0_9yvsg5vv40flojo0120h0rz6ki4g0tur.zip"
 *     }
 *   ],
 *   "nextCursor": {
 *     "cursors": {
 *       "next": ""
 *     },
 *     "hasNext": false
 *   }
 * }
 */
```

### Search files
```javascript
import { files } from '@wix/media';

async function mySearchFilesFunction() {
  try {
    const rootFiles = await files.searchFiles();

    console.log('Files in MEDIA_ROOT', rootFiles);
    return rootFiles;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "files": [
 *     {
 *       "_createdDate": "2023-07-16T08:54:05.000Z",
 *       "_id": "w8ide0_ouulk5w0mdr9omjkwsfyn71g4mb1olcf~mv2.jpg",
 *       "_updatedDate": "2023-07-16T08:54:05.000Z",
 *       "displayName": "image2.jpg",
 *       "hash": "800fae3e0cb7908518a391c25864436c",
 *       "internalTags": [
 *         "_fileOrigin_uploaded"
 *       ],
 *       "labels": [
 *         "label1",
 *         "label2",
 *         "label3",
 *         "label4"
 *       ],
 *       "media": {
 *         "image": {
 *           "colors": {
 *             "palette": [
 *               {
 *                 "rgb": {
 *                   "b": 47,
 *                   "g": 36,
 *                   "r": 31
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 155,
 *                   "g": 153,
 *                   "r": 195
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 141,
 *                   "g": 123,
 *                   "r": 138
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 177,
 *                   "g": 161,
 *                   "r": 190
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 179,
 *                   "g": 178,
 *                   "r": 217
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 160,
 *                   "g": 176,
 *                   "r": 229
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 176,
 *                   "g": 151,
 *                   "r": 162
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 93,
 *                   "g": 78,
 *                   "r": 71
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 45,
 *                   "g": 63,
 *                   "r": 107
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 104,
 *                   "g": 88,
 *                   "r": 82
 *                 }
 *               }
 *             ],
 *             "prominent": {
 *               "rgb": {
 *                 "b": 26,
 *                 "g": 36,
 *                 "r": 39
 *               }
 *             }
 *           },
 *           "faces": [],
 *           "image": "wix:image://v1/w8ide0_ouulk5w0mdr9omjkwsfyn71g4mb1olcf~mv2.jpg/image2.jpg#originWidth=5833&originHeight=3894"
 *         }
 *       },
 *       "mediaType": "IMAGE",
 *       "operationStatus": "READY",
 *       "parentFolderId": "media-root",
 *       "private": false,
 *       "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
 *       "sizeInBytes": "3013886",
 *       "state": "OK",
 *       "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_ouulk5w0mdr9omjkwsfyn71g4mb1olcf~mv2.jpg",
 *       "url": "https://static.wixstatic.com/media/w8ide0_ouulk5w0mdr9omjkwsfyn71g4mb1olcf~mv2.jpg"
 *     },
 *     {
 *       "_createdDate": "2023-07-16T08:56:07.000Z",
 *       "_id": "w8ide0_suuti24j47vesffndm8hkd651u72vp3f~mv2.jpg",
 *       "_updatedDate": "2023-07-16T08:56:07.000Z",
 *       "displayName": "image1.jpg",
 *       "hash": "fef0ylitxcnlyzxf0nahu8rh3k0i5t85",
 *       "internalTags": [
 *         "_fileOrigin_uploaded"
 *       ],
 *       "labels": [
 *         "label1"
 *       ],
 *       "media": {
 *         "image": {
 *           "colors": {
 *             "palette": [
 *               {
 *                 "rgb": {
 *                   "b": 26,
 *                   "g": 36,
 *                   "r": 39
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 135,
 *                   "g": 125,
 *                   "r": 119
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 208,
 *                   "g": 209,
 *                   "r": 208
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 40,
 *                   "g": 108,
 *                   "r": 130
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 133,
 *                   "g": 101,
 *                   "r": 75
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 36,
 *                   "g": 78,
 *                   "r": 94
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 178,
 *                   "g": 161,
 *                   "r": 148
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 192,
 *                   "g": 177,
 *                   "r": 163
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 159,
 *                   "g": 184,
 *                   "r": 208
 *                 }
 *               },
 *               {
 *                 "rgb": {
 *                   "b": 137,
 *                   "g": 159,
 *                   "r": 183
 *                 }
 *               }
 *             ],
 *             "prominent": {
 *               "rgb": {
 *                 "b": 26,
 *                 "g": 36,
 *                 "r": 39
 *               }
 *             }
 *           },
 *           "faces": [],
 *           "image": "wix:image://v1/w8ide0_suuti24j47vesffndm8hkd651u72vp3f~mv2.jpg/image1.jpg#originWidth=5616&originHeight=3744"
 *         }
 *       },
 *       "mediaType": "IMAGE",
 *       "operationStatus": "READY",
 *       "parentFolderId": "media-root",
 *       "private": false,
 *       "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
 *       "sizeInBytes": "6312959",
 *       "state": "OK",
 *       "thumbnailUrl": "https://static.wixstatic.com/media/w8ide0_suuti24j47vesffndm8hkd651u72vp3f~mv2.jpg",
 *       "url": "https://static.wixstatic.com/media/w8ide0_suuti24j47vesffndm8hkd651u72vp3f~mv2.jpg"
 *     },
 *     {
 *       "_createdDate": "2023-07-16T08:56:10.000Z",
 *       "_id": "w8ide0_9yvsg5vv40flojo0120h0rz6ki4g0tur.zip",
 *       "_updatedDate": "2023-07-16T08:56:10.000Z",
 *       "displayName": "file1.zip",
 *       "hash": "urm9iak1w39pk381ucb9kqjphya8loro",
 *       "internalTags": [
 *         "_fileOrigin_uploaded"
 *       ],
 *       "labels": [],
 *       "media": {
 *         "archive": {
 *           "_id": "w8ide0_9yvsg5vv40flojo0120h0rz6ki4g0tur.zip",
 *           "filename": "file1.zip",
 *           "sizeInBytes": "49546083",
 *           "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/archives/w8ide0_9yvsg5vv40flojo0120h0rz6ki4g0tur.zip"
 *         }
 *       },
 *       "mediaType": "ARCHIVE",
 *       "operationStatus": "READY",
 *       "parentFolderId": "media-root",
 *       "private": false,
 *       "siteId": "3ecba886-4267-11ee-be56-0242ac120002",
 *       "sizeInBytes": "49546083",
 *       "state": "OK",
 *       "thumbnailUrl": "https://static.wixstatic.com/media/48c4fbc47d7298cd4406936294b4c532.png",
 *       "url": "https://3ecba886-4267-11ee-be56-0242ac120002.usrfiles.com/archives/w8ide0_9yvsg5vv40flojo0120h0rz6ki4g0tur.zip"
 *     }
 *   ],
 *   "nextCursor": {
 *     "cursors": {
 *       "next": ""
 *     },
 *     "hasNext": false
 *   }
 * }
 */
```

### searchFiles (self-managed)
Self-managed 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 { files } from '@wix/media';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { files },
  // Include the auth strategy and host as relevant
});


async function searchFiles(options) {
  const response = await myWixClient.files.searchFiles(options);
};
```

---