> 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

# AsyncRemoveDataItemsByFilter

# Package: cms

# Namespace: DataItemService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/cms/data-items/async-remove-data-items-by-filter.md

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

## Introduction

Removes all data items matching a filter. Runs asynchronously.


This method selects all items that match the specified filter and removes each one.
Unlike [Bulk Remove Data Items](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/bulk-remove-data-items.md), you don't need to specify individual item IDs. Instead, items are selected by filter.

The operation runs asynchronously and returns a job ID for tracking status.
Call [Get Async Job Status](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/get-async-job-status.md) with the returned job ID to poll for status.

An empty `filter` removes all items in the collection.

> **Notes:**
> - The number of affected items is not bounded.
> - If any item fails to be removed, the async job stops and its status becomes `FAILED`. Some items may already have been removed before the failure.
> - Calling this method triggers the [Data Item Deleted](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/data-item-deleted.md) event for each removed item.
> - Job records are retained for 30 days. After that, querying the job ID returns `NOT_FOUND`.

---

## REST API

### Schema

```
 Method: asyncRemoveDataItemsByFilter
 Description: Removes all data items matching a filter. Runs asynchronously.   This method selects all items that match the specified filter and removes each one. Unlike [Bulk Remove Data Items](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/bulk-remove-data-items.md), you don't need to specify individual item GUIDs. Instead, items are selected by filter.  The operation runs asynchronously and returns a job GUID for tracking status. Call [Get Async Job Status](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/get-async-job-status.md) with the returned job GUID to poll for status.  An empty `filter` removes all items in the collection.  > **Notes:** > - The number of affected items is not bounded. > - If any item fails to be removed, the async job stops and its status becomes `FAILED`. Some items may already have been removed before the failure. > - Calling this method triggers the [Data Item Deleted](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/data-item-deleted.md) event for each removed item. > - Job records are retained for 30 days. After that, querying the job GUID returns `NOT_FOUND`.
 URL: https://www.wixapis.com/wix-data/v2/bulk/items/async-remove-by-filter
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  dataCollectionId
 Method parameters: 
   param name: dataCollectionId | type: dataCollectionId | description: GUID of the collection containing items to remove. | required: true | validation: maxLength 256
   param name: filter | type: filter | description: Filter to select items to remove, using [WQL filter syntax](https://dev.wix.com/docs/rest/api-reference/api-query-language/filtering.md).  Filtering is supported for fields explicitly defined in the [data collection structure](https://dev.wix.com/docs/rest/business-solutions/cms/data-collections/introduction.md#data-collections-and-their-structure). Fields not defined in the collection structure can't be used for filtering. Using an undefined field in the filter causes the async job to fail after the method returns a job GUID. Each [field type](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type) supports specific [filter operators](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md#operators). Using an unsupported operator causes the async job to fail after the method returns a job GUID. Poll [Get Async Job Status](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/get-async-job-status.md) for the final status.  An empty filter removes all items in the collection.  
   param name: publishPluginOptions | type: PublishPluginOptions    
        - name: includeDraftItems | type: boolean | description: Whether to include draft items.  When `true`, both published and draft items are affected. Default: `false`.  
 Return type: AsyncRemoveDataItemsByFilterResponse
  - name: jobId | type: string | description: Job GUID for tracking the async operation.  Call [Get Async Job Status](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/get-async-job-status.md) with this GUID to poll for status.  | validation: maxLength 256


```

### Examples

### Remove items asynchronously by filter
```curl
curl -X POST \
'https://www.wixapis.com/wix-data/v2/bulk/items/async-remove-by-filter' \
-H 'Content-Type: application/json' \
-H 'Authorization: <AUTH>' \
-d '{
  "dataCollectionId": "cities",
  "filter": {
    "archived": {
      "$eq": true
    }
  }
}'
```

---