> 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

# CreateTask

# Package: operations

# Namespace: TaskService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/cms/operations/background-tasks/create-task.md

## Permission Scopes:
Write Data Items: SCOPE.DC-DATA.WRITE
Write Data Items: SCOPE.DC-DATA.WRITE
Write Data Items: SCOPE.DC-DATA.WRITE
Write Data Items: SCOPE.DC-DATA.WRITE
Write Data Items: SCOPE.DC-DATA.WRITE

## Introduction

Creates and runs a new background task.

---

## REST API

### Schema

```
 Method: createTask
 Description: Creates and runs a new background task.
 URL: https://www.wixapis.com/cms/v1/tasks
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  task, task.type, task.deleteByQueryOptions.dataCollectionId
 Method parameters: 
   param name: task | type: Task | description: Background task job that processes data items in bulk. | required: true 
    - ONE-OF: - required: true
     - name: deleteByQueryOptions | type: DeleteByQueryOptions | description: Options for tasks of the type `DELETE_BY_QUERY`.  | validation: immutable
        - name: dataCollectionId | type: string | description: GUID of the collection from which to delete the items that match the filter. | required: true | validation: maxLength 255
        - name: environment | type: Environment | description: [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing) from which to delete item.  Default: `LIVE`.  
             - enum:
             -     SANDBOX: Collection [sandbox environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections).
             -     SANDBOX_PREFERRED: If the [collection's sandbox environment is enabled](https://support.wix.com/en/article/cms-accessing-and-syncing-your-sandbox-and-live-collections#enabling-sandbox-collections), run the task in the collection's sandbox environment. If not, run the task in the collection's live environment.
             -     LIVE: Collection [live environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#live-collections).
        - name: filter | type: object | description: Query filter. If not specified, all items are deleted.  Learn about working with [API query language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md).  
        - name: appOptions | type: object | description: Additional options specific to the [Wix app collection](https://support.wix.com/en/article/cms-formerly-content-manager-working-with-wix-app-collections) you are querying.  Learn more about [querying Wix app collections](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/querying-wix-app-collections.md).  
        - name: publishPluginOptions | type: PublishPluginOptions | description: Options for the [Publish plugin](https://support.wix.com/en/article/cms-controlling-live-site-item-visibility-from-your-collection).  This plugin allows items in a [data collection](https://dev.wix.com/docs/rest/business-solutions/cms/data-collections/data-collection-object.md) to be marked as draft or published. Published items are visible to site visitors, while draft items are not.  
           - name: includeDraftItems | type: boolean | description: Whether to include draft items.  When `true`, both published and draft items are affected. Default: `false`.  
     - name: copyFieldDataOptions | type: CopyFieldDataOptions | description: Options for tasks of the type `COPY_FIELD_DATA`.  | validation: immutable
        - name: dataCollectionId | type: string | description: GUID of the collection in which to copy and write item field data.  | validation: maxLength 255
        - name: environment | type: Environment | description: [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections) in which to copy and write field data.  Default: `LIVE`.  
        - name: sourceFieldKey | type: string | description: GUID of the field to copy data from.  | validation: maxLength 255
        - name: targetFieldKey | type: string | description: GUID of the field to copy data to.  | validation: maxLength 255
     - name: editFieldDataOptions | type: EditFieldDataOptions | description: Options for tasks of the type `EDIT_FIELD_DATA`.  | validation: immutable
        - name: dataCollectionId | type: string | description: GUID of the collection in which to edit the specified field.  | validation: maxLength 255
        - name: environment | type: Environment | description: [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections) in which to edit the specified field.  Default: `LIVE`.  
        - name: filter | type: object | description: Query filter. Only items that match the filter are edited.  Learn about working with [API query language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md).  
        - name: fieldKey | type: string | description: GUID of the field to update.  | validation: maxLength 255
        - name: operations | type: Operations | description: Operations to perform on the specified field.  
           - name: addItems | type: array<Value> | description: Add elements to a field of type Array.  Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type).  | validation: maxItems 64
              - ONE-OF: 
                 - name: nullValue | type:  | description:   
                 - name: numberValue | type: number | description:   
                 - name: stringValue | type: string | description:   
                 - name: boolValue | type: boolean | description:   
                 - name: structValue | type: object | description:   
                 - name: listValue | type: ListValue | description:   
                    - name: values | type: array<Value> | description:   
           - name: removeItems | type: array<Value> | description: Remove elements from a field of type Array.  Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type).  | validation: maxItems 64
           - name: replaceItems | type: array<Replace> | description: In a field of type Array, replace all matching elements. In a field of another type, replace all matching values.  Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type).  | validation: maxItems 64
              - name: from | type: Value | description: Value or array element to replace.  
              - name: to | type: Value | description: Value or array element to replace with.  
           - name: removeDuplicates | type: boolean | description: In a field of type Array, remove duplicate elements. Default: `false`.  Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type).  
     - name: updatePublishStatusOptions | type: UpdatePublishStatusOptions | description: Options for tasks of the type `UPDATE_PUBLISH_STATUS`.  | validation: immutable
        - ONE-OF: 
           - name: scheduleDraftStatusOptions | type: ScheduleOperation | description: In a `SCHEDULE_DRAFT_STATUS` operation, options for scheduling the status update to `DRAFT`.  
              - name: date | type: string | description: When to update the item's publish status.  | validation: format date-time
           - name: schedulePublishedStatusOptions | type: ScheduleOperation | description: In a `SCHEDULE_PUBLISHED_STATUS` operation, options for scheduling the status update to `PUBLISHED`.  
        - name: dataCollectionId | type: string | description: GUID of the collection whose items' publish status is to be updated.  | validation: maxLength 255
        - name: environment | type: Environment | description: [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections) in which to update the publish status of the items.  Default: `LIVE`.  
        - name: filter | type: object | description: Query filter. If not specified, the publish status of all items is updated.  Learn about working with [API query language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md).  
        - name: operation | type: Operation | description: Publish status update operation.  
             - enum:
             -     SET_PUBLISHED_STATUS: Update the publish status of all items that match the filter to `PUBLISHED`.
             -     SET_DRAFT_STATUS: Update the publish status of all items that match the filter to `DRAFT`.
             -     SCHEDULE_PUBLISHED_STATUS: Schedule when to update the publish status of all items that match the filter to `PUBLISHED`.
             -     SCHEDULE_DRAFT_STATUS: Schedule when to update the publish status of all items that match the filter to `DRAFT`.
             -     CANCEL_SCHEDULING: Cancel all scheduled status updates.
        - name: type | type: Type | description: Task type. | required: true | validation: immutable
             - enum:
             -     DELETE_BY_QUERY: Deletes all items that match the specified filter.
             -     COPY_FIELD_DATA: Copies data from one field to another for all items in the collection.
             -     EDIT_FIELD_DATA: Updates field data for items that match the specified filter.
             -     UPDATE_PUBLISH_STATUS: In collections that have the Publish plugin, updates the publish status of items that match the specified filter.
 Return type: CreateTaskResponse
  - name: task | type: Task | description: Created task.  
     - ONE-OF: 
        - name: deleteByQueryOptions | type: DeleteByQueryOptions | description: Options for tasks of the type `DELETE_BY_QUERY`.  | validation: immutable
           - name: dataCollectionId | type: string | description: GUID of the collection from which to delete the items that match the filter.  | validation: maxLength 255
           - name: environment | type: Environment | description: [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing) from which to delete item.  Default: `LIVE`.  
                 - enum:
                 -     SANDBOX: Collection [sandbox environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections).
                 -     SANDBOX_PREFERRED: If the [collection's sandbox environment is enabled](https://support.wix.com/en/article/cms-accessing-and-syncing-your-sandbox-and-live-collections#enabling-sandbox-collections), run the task in the collection's sandbox environment. If not, run the task in the collection's live environment.
                 -     LIVE: Collection [live environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#live-collections).
           - name: filter | type: object | description: Query filter. If not specified, all items are deleted.  Learn about working with [API query language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md).  
           - name: appOptions | type: object | description: Additional options specific to the [Wix app collection](https://support.wix.com/en/article/cms-formerly-content-manager-working-with-wix-app-collections) you are querying.  Learn more about [querying Wix app collections](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/querying-wix-app-collections.md).  
           - name: publishPluginOptions | type: PublishPluginOptions | description: Options for the [Publish plugin](https://support.wix.com/en/article/cms-controlling-live-site-item-visibility-from-your-collection).  This plugin allows items in a [data collection](https://dev.wix.com/docs/rest/business-solutions/cms/data-collections/data-collection-object.md) to be marked as draft or published. Published items are visible to site visitors, while draft items are not.  
              - name: includeDraftItems | type: boolean | description: Whether to include draft items.  When `true`, both published and draft items are affected. Default: `false`.  
        - name: copyFieldDataOptions | type: CopyFieldDataOptions | description: Options for tasks of the type `COPY_FIELD_DATA`.  | validation: immutable
           - name: dataCollectionId | type: string | description: GUID of the collection in which to copy and write item field data.  | validation: maxLength 255
           - name: environment | type: Environment | description: [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections) in which to copy and write field data.  Default: `LIVE`.  
           - name: sourceFieldKey | type: string | description: GUID of the field to copy data from.  | validation: maxLength 255
           - name: targetFieldKey | type: string | description: GUID of the field to copy data to.  | validation: maxLength 255
        - name: editFieldDataOptions | type: EditFieldDataOptions | description: Options for tasks of the type `EDIT_FIELD_DATA`.  | validation: immutable
           - name: dataCollectionId | type: string | description: GUID of the collection in which to edit the specified field.  | validation: maxLength 255
           - name: environment | type: Environment | description: [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections) in which to edit the specified field.  Default: `LIVE`.  
           - name: filter | type: object | description: Query filter. Only items that match the filter are edited.  Learn about working with [API query language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md).  
           - name: fieldKey | type: string | description: GUID of the field to update.  | validation: maxLength 255
           - name: operations | type: Operations | description: Operations to perform on the specified field.  
              - name: addItems | type: array<Value> | description: Add elements to a field of type Array.  Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type).  | validation: maxItems 64
                 - ONE-OF: 
                    - name: nullValue | type:  | description:   
                    - name: numberValue | type: number | description:   
                    - name: stringValue | type: string | description:   
                    - name: boolValue | type: boolean | description:   
                    - name: structValue | type: object | description:   
                    - name: listValue | type: ListValue | description:   
                       - name: values | type: array<Value> | description:   
              - name: removeItems | type: array<Value> | description: Remove elements from a field of type Array.  Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type).  | validation: maxItems 64
              - name: replaceItems | type: array<Replace> | description: In a field of type Array, replace all matching elements. In a field of another type, replace all matching values.  Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type).  | validation: maxItems 64
                 - name: from | type: Value | description: Value or array element to replace.  
                 - name: to | type: Value | description: Value or array element to replace with.  
              - name: removeDuplicates | type: boolean | description: In a field of type Array, remove duplicate elements. Default: `false`.  Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type).  
        - name: updatePublishStatusOptions | type: UpdatePublishStatusOptions | description: Options for tasks of the type `UPDATE_PUBLISH_STATUS`.  | validation: immutable
           - ONE-OF: 
              - name: scheduleDraftStatusOptions | type: ScheduleOperation | description: In a `SCHEDULE_DRAFT_STATUS` operation, options for scheduling the status update to `DRAFT`.  
                 - name: date | type: string | description: When to update the item's publish status.  | validation: format date-time
              - name: schedulePublishedStatusOptions | type: ScheduleOperation | description: In a `SCHEDULE_PUBLISHED_STATUS` operation, options for scheduling the status update to `PUBLISHED`.  
           - name: dataCollectionId | type: string | description: GUID of the collection whose items' publish status is to be updated.  | validation: maxLength 255
           - name: environment | type: Environment | description: [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections) in which to update the publish status of the items.  Default: `LIVE`.  
           - name: filter | type: object | description: Query filter. If not specified, the publish status of all items is updated.  Learn about working with [API query language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md).  
           - name: operation | type: Operation | description: Publish status update operation.  
                 - enum:
                 -     SET_PUBLISHED_STATUS: Update the publish status of all items that match the filter to `PUBLISHED`.
                 -     SET_DRAFT_STATUS: Update the publish status of all items that match the filter to `DRAFT`.
                 -     SCHEDULE_PUBLISHED_STATUS: Schedule when to update the publish status of all items that match the filter to `PUBLISHED`.
                 -     SCHEDULE_DRAFT_STATUS: Schedule when to update the publish status of all items that match the filter to `DRAFT`.
                 -     CANCEL_SCHEDULING: Cancel all scheduled status updates.
     - name: id | type: string | description: Task GUID.  | read-only: true | validation: format GUID
     - name: type | type: Type | description: Task type.  | validation: immutable
         - enum:
         -     DELETE_BY_QUERY: Deletes all items that match the specified filter.
         -     COPY_FIELD_DATA: Copies data from one field to another for all items in the collection.
         -     EDIT_FIELD_DATA: Updates field data for items that match the specified filter.
         -     UPDATE_PUBLISH_STATUS: In collections that have the Publish plugin, updates the publish status of items that match the specified filter.
     - name: status | type: Status | description: Task status.  | read-only: true 
         - enum:
         -     NEW: Task was created but has not started.
         -     RUNNING: Task is currently running.
         -     COMPLETED: Task has completed. Partial errors are listed in `failures`.
         -     FAILED: Task has failed. Tasks can fail due to errors or because they were cancelled.  Failures are listed in `failures`. Cancelled tasks have a failure `code` value of `CANCELLED`, and no associated failure `data`.
     - name: startedAt | type: string | description: Task start time. Empty if the task status is `NEW`.  | read-only: true | validation: format date-time
     - name: finishedAt | type: string | description: Task finish time. Empty until the task status updates to `COMPLETED` or `FAILED`.  | read-only: true | validation: format date-time
     - name: itemsFailed | type: integer | description: Number of items whose processing failed.  | read-only: true 
     - name: failures | type: array<ApplicationError> | description: List of errors generated during the task.  Learn more about [Wix Data error codes](https://dev.wix.com/docs/sdk/backend-modules/data/wix-data-error-codes.md).  | read-only: true | validation: maxItems 100
        - name: code | type: string | description: Error code.  
        - name: description | type: string | description: Description of the error.  
        - name: data | type: object | description: Data related to the error.  
     - name: estimatedItemCount | type: integer | description: Estimated number of items affected by the task.  | read-only: true 
     - name: itemsSucceeded | type: integer | description: Number of items successfully processed so far.  | read-only: true 


```

### Examples

### Create Update Publish Status task
```curl
curl -X POST https://wixapis.com/autocms/v1/tasks  \
    -H 'Authorization: <AUTH>' \
    -H 'Content-Type: application/json' \
    -d '{
          "task": {
            "type": "UPDATE_PUBLISH_STATUS",
            "updatePublishStatusOptions": {
              "dataCollectionId": "Items",
              "environment": "LIVE",
              "filter": {
                "holidays": {
                  "$in": ["Halloween"]
                }
              },
              "operation": "SCHEDULE_PUBLISHED_STATUS",
              "schedulePublishedStatusOptions": {
                  "date": "2025-01-01T10:00:00Z"
              }
            }
          }
        }'
```

### Create Copy Field Data task
```curl
curl -X POST https://wixapis.com/autocms/v1/tasks  \
    -H 'Authorization: <AUTH>' \
    -H 'Content-Type: application/json' \
    -d '{
        "task": {
            "type": "COPY_FIELD_DATA",
            "copyFieldDataOptions": {
                "dataCollectionId": "Items",
                "environment": "LIVE",
                "sourceFieldKey": "fullName",
                "targetFieldKey": "fullNameCopy"
            }
        }
      }'
```

### Create Edit Field Data task
```curl
curl -X POST https://wixapis.com/autocms/v1/tasks  \
    -H 'Authorization: <AUTH>' \
    -H 'Content-Type: application/json' \
    -d '{
        "task": {
            "type": "EDIT_FIELD_DATA",
            "editFieldDataOptions": {
                "dataCollectionId": "Items",
                "environment": "LIVE",
                "filter": {
                  "holidays": {
                    "$in": ["Halloween"]
                  }
                },
                "fieldKey": "tags",
                "operations": {
                    "addItems": ["sale"],
                    "removeItems": ["outdated"],
                    "replaceItems": [{
                        "from": "Goob",
                        "to": "Good"
                    }],
                    "removeDuplicates": true
                }
            }
        }
      }'
```

### Create Delete By Query task
```curl
curl -X POST https://wixapis.com/autocms/v1/tasks  \
    -H 'Authorization: <AUTH>' \
    -H 'Content-Type: application/json' \
    -d '{
        "task": {
          "type": "DELETE_BY_QUERY",
          "deleteByQueryOptions": {
            "dataCollectionId": "Items",
            "environment": "LIVE",
            "filter": {
              "holidays": {
                "$in": ["Halloween"]
              }
            },
          }
        }
      }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.data.tasks.createTask(task)
 Description: Creates and runs a new background task.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  task, task.type, task.deleteByQueryOptions.dataCollectionId, task.updatePublishStatusOptions.dataCollectionId, task.updatePublishStatusOptions.operation, task.copyFieldDataOptions.dataCollectionId, task.copyFieldDataOptions.sourceFieldKey, task.copyFieldDataOptions.targetFieldKey, task.editFieldDataOptions.dataCollectionId, task.editFieldDataOptions.fieldKey
 Method parameters: 
   param name: task | type: Task | description: Background task job that processes data items in bulk. | required: true 
    - ONE-OF: - required: true
     - name: deleteByQueryOptions | type: DeleteByQueryOptions | description: Options for tasks of the type `DELETE_BY_QUERY`.  | validation: immutable
        - name: dataCollectionId | type: string | description: GUID of the collection from which to delete the items that match the filter. | required: true | validation: maxLength 255
        - name: environment | type: Environment | description: [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing) from which to delete item.  Default: `LIVE`.  
             - enum:
             -     SANDBOX: Collection [sandbox environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections).
             -     SANDBOX_PREFERRED: If the [collection's sandbox environment is enabled](https://support.wix.com/en/article/cms-accessing-and-syncing-your-sandbox-and-live-collections#enabling-sandbox-collections), run the task in the collection's sandbox environment. If not, run the task in the collection's live environment.
             -     LIVE: Collection [live environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#live-collections).
        - name: filter | type: object | description: Query filter. If not specified, all items are deleted.  Learn about working with [API query language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md).  
        - name: appOptions | type: object | description: Additional options specific to the [Wix app collection](https://support.wix.com/en/article/cms-formerly-content-manager-working-with-wix-app-collections) you are querying.  Learn more about [querying Wix app collections](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/querying-wix-app-collections.md).  
        - name: publishPluginOptions | type: PublishPluginOptions | description: Options for the [Publish plugin](https://support.wix.com/en/article/cms-controlling-live-site-item-visibility-from-your-collection).  This plugin allows items in a [data collection](https://dev.wix.com/docs/rest/business-solutions/cms/data-collections/data-collection-object.md) to be marked as draft or published. Published items are visible to site visitors, while draft items are not.  
           - name: includeDraftItems | type: boolean | description: Whether to include draft items.  When `true`, both published and draft items are affected. Default: `false`.  
     - name: copyFieldDataOptions | type: CopyFieldDataOptions | description: Options for tasks of the type `COPY_FIELD_DATA`.  | validation: immutable
        - name: dataCollectionId | type: string | description: GUID of the collection in which to copy and write item field data.  | validation: maxLength 255
        - name: environment | type: Environment | description: [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections) in which to copy and write field data.  Default: `LIVE`.  
        - name: sourceFieldKey | type: string | description: GUID of the field to copy data from.  | validation: maxLength 255
        - name: targetFieldKey | type: string | description: GUID of the field to copy data to.  | validation: maxLength 255
     - name: editFieldDataOptions | type: EditFieldDataOptions | description: Options for tasks of the type `EDIT_FIELD_DATA`.  | validation: immutable
        - name: dataCollectionId | type: string | description: GUID of the collection in which to edit the specified field.  | validation: maxLength 255
        - name: environment | type: Environment | description: [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections) in which to edit the specified field.  Default: `LIVE`.  
        - name: filter | type: object | description: Query filter. Only items that match the filter are edited.  Learn about working with [API query language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md).  
        - name: fieldKey | type: string | description: GUID of the field to update.  | validation: maxLength 255
        - name: operations | type: Operations | description: Operations to perform on the specified field.  
           - name: addItems | type: array<Value> | description: Add elements to a field of type Array.  Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type).  | validation: maxItems 64
              - ONE-OF: 
                 - name: nullValue | type:  | description:   
                 - name: numberValue | type: number | description:   
                 - name: stringValue | type: string | description:   
                 - name: boolValue | type: boolean | description:   
                 - name: structValue | type: object | description:   
                 - name: listValue | type: ListValue | description:   
                    - name: values | type: array<Value> | description:   
           - name: removeItems | type: array<Value> | description: Remove elements from a field of type Array.  Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type).  | validation: maxItems 64
           - name: replaceItems | type: array<Replace> | description: In a field of type Array, replace all matching elements. In a field of another type, replace all matching values.  Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type).  | validation: maxItems 64
              - name: from | type: Value | description: Value or array element to replace.  
              - name: to | type: Value | description: Value or array element to replace with.  
           - name: removeDuplicates | type: boolean | description: In a field of type Array, remove duplicate elements. Default: `false`.  Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type).  
     - name: updatePublishStatusOptions | type: UpdatePublishStatusOptions | description: Options for tasks of the type `UPDATE_PUBLISH_STATUS`.  | validation: immutable
        - ONE-OF: 
           - name: scheduleDraftStatusOptions | type: ScheduleOperation | description: In a `SCHEDULE_DRAFT_STATUS` operation, options for scheduling the status update to `DRAFT`.  
              - name: date | type: Date | description: When to update the item's publish status.  
           - name: schedulePublishedStatusOptions | type: ScheduleOperation | description: In a `SCHEDULE_PUBLISHED_STATUS` operation, options for scheduling the status update to `PUBLISHED`.  
        - name: dataCollectionId | type: string | description: GUID of the collection whose items' publish status is to be updated.  | validation: maxLength 255
        - name: environment | type: Environment | description: [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections) in which to update the publish status of the items.  Default: `LIVE`.  
        - name: filter | type: object | description: Query filter. If not specified, the publish status of all items is updated.  Learn about working with [API query language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md).  
        - name: operation | type: Operation | description: Publish status update operation.  
             - enum:
             -     SET_PUBLISHED_STATUS: Update the publish status of all items that match the filter to `PUBLISHED`.
             -     SET_DRAFT_STATUS: Update the publish status of all items that match the filter to `DRAFT`.
             -     SCHEDULE_PUBLISHED_STATUS: Schedule when to update the publish status of all items that match the filter to `PUBLISHED`.
             -     SCHEDULE_DRAFT_STATUS: Schedule when to update the publish status of all items that match the filter to `DRAFT`.
             -     CANCEL_SCHEDULING: Cancel all scheduled status updates.
        - name: type | type: Type | description: Task type. | required: true | validation: immutable
             - enum:
             -     DELETE_BY_QUERY: Deletes all items that match the specified filter.
             -     COPY_FIELD_DATA: Copies data from one field to another for all items in the collection.
             -     EDIT_FIELD_DATA: Updates field data for items that match the specified filter.
             -     UPDATE_PUBLISH_STATUS: In collections that have the Publish plugin, updates the publish status of items that match the specified filter.
 Return type: PROMISE<Task>
  - ONE-OF: 
     - name: deleteByQueryOptions | type: DeleteByQueryOptions | description: Options for tasks of the type `DELETE_BY_QUERY`.  | validation: immutable
        - name: dataCollectionId | type: string | description: GUID of the collection from which to delete the items that match the filter.  | validation: maxLength 255
        - name: environment | type: Environment | description: [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing) from which to delete item.  Default: `LIVE`.  
             - enum:
             -     SANDBOX: Collection [sandbox environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections).
             -     SANDBOX_PREFERRED: If the [collection's sandbox environment is enabled](https://support.wix.com/en/article/cms-accessing-and-syncing-your-sandbox-and-live-collections#enabling-sandbox-collections), run the task in the collection's sandbox environment. If not, run the task in the collection's live environment.
             -     LIVE: Collection [live environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#live-collections).
        - name: filter | type: object | description: Query filter. If not specified, all items are deleted.  Learn about working with [API query language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md).  
        - name: appOptions | type: object | description: Additional options specific to the [Wix app collection](https://support.wix.com/en/article/cms-formerly-content-manager-working-with-wix-app-collections) you are querying.  Learn more about [querying Wix app collections](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/querying-wix-app-collections.md).  
        - name: publishPluginOptions | type: PublishPluginOptions | description: Options for the [Publish plugin](https://support.wix.com/en/article/cms-controlling-live-site-item-visibility-from-your-collection).  This plugin allows items in a [data collection](https://dev.wix.com/docs/rest/business-solutions/cms/data-collections/data-collection-object.md) to be marked as draft or published. Published items are visible to site visitors, while draft items are not.  
           - name: includeDraftItems | type: boolean | description: Whether to include draft items.  When `true`, both published and draft items are affected. Default: `false`.  
     - name: copyFieldDataOptions | type: CopyFieldDataOptions | description: Options for tasks of the type `COPY_FIELD_DATA`.  | validation: immutable
        - name: dataCollectionId | type: string | description: GUID of the collection in which to copy and write item field data.  | validation: maxLength 255
        - name: environment | type: Environment | description: [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections) in which to copy and write field data.  Default: `LIVE`.  
        - name: sourceFieldKey | type: string | description: GUID of the field to copy data from.  | validation: maxLength 255
        - name: targetFieldKey | type: string | description: GUID of the field to copy data to.  | validation: maxLength 255
     - name: editFieldDataOptions | type: EditFieldDataOptions | description: Options for tasks of the type `EDIT_FIELD_DATA`.  | validation: immutable
        - name: dataCollectionId | type: string | description: GUID of the collection in which to edit the specified field.  | validation: maxLength 255
        - name: environment | type: Environment | description: [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections) in which to edit the specified field.  Default: `LIVE`.  
        - name: filter | type: object | description: Query filter. Only items that match the filter are edited.  Learn about working with [API query language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md).  
        - name: fieldKey | type: string | description: GUID of the field to update.  | validation: maxLength 255
        - name: operations | type: Operations | description: Operations to perform on the specified field.  
           - name: addItems | type: array<Value> | description: Add elements to a field of type Array.  Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type).  | validation: maxItems 64
              - ONE-OF: 
                 - name: nullValue | type:  | description:   
                 - name: numberValue | type: number | description:   
                 - name: stringValue | type: string | description:   
                 - name: boolValue | type: boolean | description:   
                 - name: structValue | type: object | description:   
                 - name: listValue | type: ListValue | description:   
                    - name: values | type: array<Value> | description:   
           - name: removeItems | type: array<Value> | description: Remove elements from a field of type Array.  Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type).  | validation: maxItems 64
           - name: replaceItems | type: array<Replace> | description: In a field of type Array, replace all matching elements. In a field of another type, replace all matching values.  Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type).  | validation: maxItems 64
              - name: from | type: Value | description: Value or array element to replace.  
              - name: to | type: Value | description: Value or array element to replace with.  
           - name: removeDuplicates | type: boolean | description: In a field of type Array, remove duplicate elements. Default: `false`.  Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type).  
     - name: updatePublishStatusOptions | type: UpdatePublishStatusOptions | description: Options for tasks of the type `UPDATE_PUBLISH_STATUS`.  | validation: immutable
        - ONE-OF: 
           - name: scheduleDraftStatusOptions | type: ScheduleOperation | description: In a `SCHEDULE_DRAFT_STATUS` operation, options for scheduling the status update to `DRAFT`.  
              - name: date | type: Date | description: When to update the item's publish status.  
           - name: schedulePublishedStatusOptions | type: ScheduleOperation | description: In a `SCHEDULE_PUBLISHED_STATUS` operation, options for scheduling the status update to `PUBLISHED`.  
        - name: dataCollectionId | type: string | description: GUID of the collection whose items' publish status is to be updated.  | validation: maxLength 255
        - name: environment | type: Environment | description: [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections) in which to update the publish status of the items.  Default: `LIVE`.  
        - name: filter | type: object | description: Query filter. If not specified, the publish status of all items is updated.  Learn about working with [API query language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md).  
        - name: operation | type: Operation | description: Publish status update operation.  
             - enum:
             -     SET_PUBLISHED_STATUS: Update the publish status of all items that match the filter to `PUBLISHED`.
             -     SET_DRAFT_STATUS: Update the publish status of all items that match the filter to `DRAFT`.
             -     SCHEDULE_PUBLISHED_STATUS: Schedule when to update the publish status of all items that match the filter to `PUBLISHED`.
             -     SCHEDULE_DRAFT_STATUS: Schedule when to update the publish status of all items that match the filter to `DRAFT`.
             -     CANCEL_SCHEDULING: Cancel all scheduled status updates.
  - name: _id | type: string | description: Task GUID.  | read-only: true | validation: format GUID
  - name: type | type: Type | description: Task type.  | validation: immutable
     - enum:
     -     DELETE_BY_QUERY: Deletes all items that match the specified filter.
     -     COPY_FIELD_DATA: Copies data from one field to another for all items in the collection.
     -     EDIT_FIELD_DATA: Updates field data for items that match the specified filter.
     -     UPDATE_PUBLISH_STATUS: In collections that have the Publish plugin, updates the publish status of items that match the specified filter.
  - name: status | type: Status | description: Task status.  | read-only: true 
     - enum:
     -     NEW: Task was created but has not started.
     -     RUNNING: Task is currently running.
     -     COMPLETED: Task has completed. Partial errors are listed in `failures`.
     -     FAILED: Task has failed. Tasks can fail due to errors or because they were cancelled.  Failures are listed in `failures`. Cancelled tasks have a failure `code` value of `CANCELLED`, and no associated failure `data`.
  - name: startedAt | type: Date | description: Task start time. Empty if the task status is `NEW`.  | read-only: true 
  - name: finishedAt | type: Date | description: Task finish time. Empty until the task status updates to `COMPLETED` or `FAILED`.  | read-only: true 
  - name: itemsFailed | type: integer | description: Number of items whose processing failed.  | read-only: true 
  - name: failures | type: array<ApplicationError> | description: List of errors generated during the task.  Learn more about [Wix Data error codes](https://dev.wix.com/docs/sdk/backend-modules/data/wix-data-error-codes.md).  | read-only: true | validation: maxItems 100
     - name: code | type: string | description: Error code.  
     - name: description | type: string | description: Description of the error.  
     - name: data | type: object | description: Data related to the error.  
  - name: estimatedItemCount | type: integer | description: Estimated number of items affected by the task.  | read-only: true 
  - name: itemsSucceeded | type: integer | description: Number of items successfully processed so far.  | read-only: true 


```

### Examples

### createTask
```javascript
import { tasks } from '@wix/data';

async function createTask(task) {
  const response = await tasks.createTask(task);
};
```

### createTask (with elevated permissions)
```javascript
import { tasks } from '@wix/data';
import { auth } from '@wix/essentials';

async function myCreateTaskMethod(task) {
  const elevatedCreateTask = auth.elevate(tasks.createTask);
  const response = await elevatedCreateTask(task);
}
```

### createTask (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 { tasks } from '@wix/data';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function createTask(task) {
  const response = await myWixClient.tasks.createTask(task);
};
```

---