> 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

## Resource: Sample Flows

## Article: Sample Flows

## Article Link: https://dev.wix.com/docs/api-reference/business-solutions/cms/operations/background-tasks/sample-flows.md

## Article Content:

# Sample Flows

This article presents possible sample flows that you can support. This can be a helpful jumping-off point as you plan your implementation.

> **Note**: Learn more about querying data collections using [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md).

## Set items' Publish status

On a [data collection](https://dev.wix.com/docs/rest/business-solutions/cms/data-collections/introduction.md) that has the Publish plugin, create a task to publish all special-edition holiday items at the specified time:

1. Call [Create Task](https://dev.wix.com/docs/rest/business-solutions/cms/background-tasks/create-task.md) and specify the following parameters:

    ```json
    {
      "task": {
        "type": "UPDATE_PUBLISH_STATUS",
        "updatePublishStatusOptions": {
          "dataCollectionId": "products",
          "filter": {
            "holidays": {
              "$in": ["Halloween"]
            }
          },
          "operation": "SCHEDULE_PUBLISHED_STATUS",
          "schedulePublishedStatusOptions": {
            "date": "2024-10-24T10:00:00Z"
          }
        }
      }
    }
    ```

    The method returns the following response:

    ```json
    {
      "task": {
        "id": "b8815393-3bca-4de7-b592-53eeb1465a61",
        "type": "UPDATE_PUBLISH_STATUS",
        "status": "NEW",
        "startedAt": "2024-09-05T10:34:59.507Z",
        "estimatedItemCount": 5,
        "itemsSucceeded": 0,
        "itemsFailed": 0,
        "failures": [],
        "updatePublishStatusOptions": {
          "dataCollectionId": "Products",
          "filter": {
            "holidays": {
              "$in": ["Halloween"]
            }
          },
          "operation": "SCHEDULE_PUBLISHED_STATUS",
          "schedulePublishedStatusOptions": {
            "date": "2024-10-24T10:00:00Z"
          }
        }
      }
    }
    ```

2. At any point, you can check the task status by calling the [Get Task](https://dev.wix.com/docs/rest/business-solutions/cms/background-tasks/get-task.md) method with the task ID.

    The method returns a response such as:

    ```json
    {
      "task": {
        "id": "b8815393-3bca-4de7-b592-53eeb1465a61",
        "type": "SCHEDULE_PUBLISHED_STATUS",
        "status": "FAILED",
        "startedAt": "2024-09-05T10:34:59.507Z",
        "finishedAt": "2024-09-05T10:35:03.654Z",
        "estimatedItemCount": 4,
        "itemsSucceeded": 0,
        "itemsFailed": 4,
        "failures": [{
          "code": 404, 
          "description": "Collection not found.",
          "data": {
            "dataCollectionId": "Products"
          }}],
        "updatePublishStatusOptions": {
          "dataCollectionId": "Products",
          "filter": {
            "holidays": {
              "$in": ["Halloween"]
            }
          },
          "operation": "SCHEDULE_PUBLISHED_STATUS",
          "schedulePublishedStatusOptions": {
            "date": "2024-10-24T10:00:00Z"
          }
        }
      }
    }
    ```

## Delete items by query

Create a task to retrieve and delete all products from a specified manufacturer:

1. Call [Create Task](https://dev.wix.com/docs/rest/business-solutions/cms/background-tasks/create-task.md) and specify the following parameters:

    ```json
    {
      "task": {
        "type": "DELETE_BY_QUERY",
        "deleteByQueryOptions": {
          "dataCollectionId": "Products",
          "filter": {
            "manufacturer": "BadAcme"
          }
        }
      }
    }
    ```

    The method might return the following response:

    ```json
    {
      "task": {
        "id": "097a5564-0fec-4425-8d1e-3e753b48a422",
        "type": "DELETE_BY_QUERY",
        "status": "NEW",
        "startedAt": "2024-09-05T10:34:59.507Z",
        "estimatedItemCount": 3,
        "itemsSucceeded": 0,
        "itemsFailed": 0,
        "failures": [],
        "deleteByQueryOptions": {
          "dataCollectionId": "Products",
          "filter": {
            "manufacturer": "BadAcme"
          }
        }
      }
    }
    ```

2. At any point, you can check the task status by calling the [Get Task](https://dev.wix.com/docs/rest/business-solutions/cms/background-tasks/get-task.md) method with the task ID.

  The method returns a response such as:

  ```json
  {
    "task": {
      "id": "097a5564-0fec-4425-8d1e-3e753b48a422",
      "type": "DELETE_BY_QUERY",
      "status": "COMPLETED",
      "startedAt": "2024-09-05T10:34:59.507Z",
      "finishedAt": "2024-09-05T10:35:03.654Z",
      "estimatedItemCount": 3,
      "itemsSucceeded": 3,
      "itemsFailed": 0,
      "failures": [],
      "deleteByQueryOptions": {
        "dataCollectionId": "Products",
        "filter": {
          "manufacturer": "BadAcme"
        }
      }
    }
  }
  ```