> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # ListTasks # Package: operations # Namespace: TaskService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/cms/operations/background-tasks/list-tasks.md ## Permission Scopes: Write Data Items: SCOPE.DC-DATA.WRITE ## Introduction Lists all existing tasks. --- ## REST API ### Schema ``` Method: listTasks Description: Lists all existing tasks. URL: https://www.wixapis.com/v1 Method: GET Method parameters: param name: paging | type: Paging - name: limit | type: integer | description: Number of items to load. - name: offset | type: integer | description: Number of items to skip in the current sort order. Return type: ListTasksResponse - name: tasks | type: array | description: Retrieved tasks. - ONE-OF: - name: deleteByQueryOptions | type: DeleteByQueryOptions | description: Options for tasks of the type `DELETE_BY_QUERY`. - name: dataCollectionId | type: string | description: GUID of the collection from which to delete the items that match the filter. - 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`. - name: dataCollectionId | type: string | description: GUID of the collection in which to copy and write item field data. - 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. - name: targetFieldKey | type: string | description: GUID of the field to copy data to. - name: editFieldDataOptions | type: EditFieldDataOptions | description: Options for tasks of the type `EDIT_FIELD_DATA`. - name: dataCollectionId | type: string | description: GUID of the collection in which to edit the specified field. - 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. - name: operations | type: Operations | description: Operations to perform on the specified field. - name: addItems | type: array | 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). - 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 | description: - name: removeItems | type: array | 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). - name: replaceItems | type: array | 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). - 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`. - 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. - 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. - 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. - name: type | type: Type | description: Task type. - 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. - 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`. - name: finishedAt | type: string | description: Task finish time. Empty until the task status updates to `COMPLETED` or `FAILED`. - name: itemsFailed | type: integer | description: Number of items whose processing failed. - name: failures | type: array | 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). - 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. - name: itemsSucceeded | type: integer | description: Number of items successfully processed so far. - name: metadata | type: PagingMetadataV2 | description: Paging metadata. - name: count | type: integer | description: Number of items returned in the response. - name: offset | type: integer | description: Offset that was requested. - name: total | type: integer | description: Total number of items that match the query. Returned if offset paging is used and the `tooManyToCount` flag is not set. - name: tooManyToCount | type: boolean | description: Flag that indicates the server failed to calculate the `total` field. - 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. - name: prev | type: string | description: Cursor pointing to the previous page in the list of results. ``` ### Examples ### List tasks ```curl curl -X GET https://wixapis.com/autocms/v1/tasks?paging.offset=5 \ -H 'Authorization: ' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.operations.TaskService.listTasks(options) Description: Lists all existing tasks. Method parameters: param name: options | type: ListTasksOptions none - name: paging | type: Paging | description: Paginating information. This has the following default values: - `limit`: 30 - `offset`: 0 - name: limit | type: integer | description: Number of items to load. - name: offset | type: integer | description: Number of items to skip in the current sort order. Return type: PROMISE - name: tasks | type: array | description: Retrieved tasks. - ONE-OF: - name: deleteByQueryOptions | type: DeleteByQueryOptions | description: Options for tasks of the type `DELETE_BY_QUERY`. - name: dataCollectionId | type: string | description: GUID of the collection from which to delete the items that match the filter. - 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`. - name: dataCollectionId | type: string | description: GUID of the collection in which to copy and write item field data. - 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. - name: targetFieldKey | type: string | description: GUID of the field to copy data to. - name: editFieldDataOptions | type: EditFieldDataOptions | description: Options for tasks of the type `EDIT_FIELD_DATA`. - name: dataCollectionId | type: string | description: GUID of the collection in which to edit the specified field. - 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. - name: operations | type: Operations | description: Operations to perform on the specified field. - name: addItems | type: array | 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). - 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 | description: - name: removeItems | type: array | 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). - name: replaceItems | type: array | 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). - 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`. - 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. - 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. - name: type | type: Type | description: Task type. - 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. - 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`. - name: finishedAt | type: Date | description: Task finish time. Empty until the task status updates to `COMPLETED` or `FAILED`. - name: itemsFailed | type: integer | description: Number of items whose processing failed. - name: failures | type: array | 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). - 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. - name: itemsSucceeded | type: integer | description: Number of items successfully processed so far. - name: metadata | type: PagingMetadataV2 | description: Paging metadata. - name: count | type: integer | description: Number of items returned in the response. - name: offset | type: integer | description: Offset that was requested. - name: total | type: integer | description: Total number of items that match the query. Returned if offset paging is used and the `tooManyToCount` flag is not set. - name: tooManyToCount | type: boolean | description: Flag that indicates the server failed to calculate the `total` field. - 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. - name: prev | type: string | description: Cursor pointing to the previous page in the list of results. ``` ### Examples ### listTasks ```javascript import { tasks } from '@wix/data'; async function listTasks(options) { const response = await tasks.listTasks(options); }; ``` ### listTasks (with elevated permissions) ```javascript import { tasks } from '@wix/data'; import { auth } from '@wix/essentials'; async function myListTasksMethod(options) { const elevatedListTasks = auth.elevate(tasks.listTasks); const response = await elevatedListTasks(options); } ``` ### listTasks (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { 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 listTasks(options) { const response = await myWixClient.tasks.listTasks(options); }; ``` ---