> 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

# BulkDeleteContactsByFilter

# Package: contacts

# Namespace: Contacts

# Method link: https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/contacts-v5/bulk-delete-contacts-by-filter.md

## Permission Scopes:
Manage Contacts: SCOPE.DC-CONTACTS.MANAGE-CONTACTS
Manage Members: SCOPE.DC-MEMBERS.MANAGE-MEMBERS

## Introduction

Deletes multiple contacts that match the provided filter. Works asynchronously.

All contacts that meet the specified `filter` and `search` criteria are deleted. The request must contain a `filter` value, a `search` value, or both. An empty `filter` (`{}`) without a `search` value matches all contacts, so all of the site's contacts are deleted. To preview which contacts match before deleting, call [Search Contacts](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/contacts-v5/search-contacts.md) with the same criteria.

To check the status of the bulk deletion, pass the returned `jobId` to [Get Async Job](https://dev.wix.com/docs/api-reference/business-management/async-job/get-async-job.md).

Deleted contacts are moved to the trash bin and can be restored within 90 days by calling [Restore Contact From Trash Bin](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/contacts-v5/restore-contact-from-trash-bin.md) or [Bulk Restore Contacts From Trash Bin](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/contacts-v5/bulk-restore-contacts-from-trash-bin.md).

Individual contacts can fail during processing. These failures appear in the job's results with one of the following error codes:
- `CANNOT_DELETE_SITE_MEMBERS`: Contact is a site member and can't be deleted. The site member must be deleted first.
- `CANNOT_DELETE_CONTACT_WITH_BILLING_SUBSCRIPTION`: Contact has an active billing subscription and can't be deleted.
- `CANNOT_DELETE_WIX_USERS_MEMBER`: Site member can't be deleted because it's the owner or a contributor.
- `FAILED_DELETE_CONTACT_AFTER_MEMBER_DELETION`: Site member was deleted, but the contact was not.
- `FAILED_DELETE_CONTACT`: Contact couldn't be deleted.

---

## REST API

### Schema

```
 Method: bulkDeleteContactsByFilter
 Description: Deletes multiple contacts that match the provided filter. Works asynchronously.  All contacts that meet the specified `filter` and `search` criteria are deleted. The request must contain a `filter` value, a `search` value, or both. An empty `filter` (`{}`) without a `search` value matches all contacts, so all of the site's contacts are deleted. To preview which contacts match before deleting, call [Search Contacts](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/contacts-v5/search-contacts.md) with the same criteria.  To check the status of the bulk deletion, pass the returned `jobId` to [Get Async Job](https://dev.wix.com/docs/api-reference/business-management/async-job/get-async-job.md).  Deleted contacts are moved to the trash bin and can be restored within 90 days by calling [Restore Contact From Trash Bin](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/contacts-v5/restore-contact-from-trash-bin.md) or [Bulk Restore Contacts From Trash Bin](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/contacts-v5/bulk-restore-contacts-from-trash-bin.md).  Individual contacts can fail during processing. These failures appear in the job's results with one of the following error codes: - `CANNOT_DELETE_SITE_MEMBERS`: Contact is a site member and can't be deleted. The site member must be deleted first. - `CANNOT_DELETE_CONTACT_WITH_BILLING_SUBSCRIPTION`: Contact has an active billing subscription and can't be deleted. - `CANNOT_DELETE_WIX_USERS_MEMBER`: Site member can't be deleted because it's the owner or a contributor. - `FAILED_DELETE_CONTACT_AFTER_MEMBER_DELETION`: Site member was deleted, but the contact was not. - `FAILED_DELETE_CONTACT`: Contact couldn't be deleted.
 URL: https://www.wixapis.com/contacts/v5/bulk/contacts/delete-by-filter
 Method: POST
 Method parameters:
   param name: deleteMembers | type: deleteMembers | description: Whether to delete the associated site member for any contact that's a site member. If `true`, the site member is also deleted.  Default: `false`  
   param name: filter | type: filter | description: Filter object. An empty filter (`{}`) matches all contacts.  Example: `{ "filter": { "name.last": "Smith" } }`  
   param name: search | type: SearchDetails    
        - name: mode | type: Mode | description: How separate search terms in `expression` are combined.  
             - enum:
             -     OR: Any of the search terms must be present.
             -     AND: All search terms must be present.
        - name: expression | type: string | description: Search term or expression.  | validation: maxLength 100
        - name: fields | type: array<string> | description: Fields to search in. If empty, searches all searchable fields. Use dot notation to specify the JSON path.  | validation: maxItems 20, maxLength 200
        - name: fuzzy | type: boolean | description: Whether to use fuzzy search, which allows typos using a managed proximity algorithm.  
 Return type: BulkDeleteContactsByFilterResponse
  - name: jobId | type: string | description: Job GUID. Pass this GUID to [Get Async Job](https://dev.wix.com/docs/api-reference/business-management/async-job/get-async-job.md) to retrieve the status of the asynchronous operation.  | validation: format GUID

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: MISSING_FILTER_AND_SEARCH | Description: The request must contain a `filter` value, a `search` value, or both.
   HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: UNAUTHORIZED_DELETE_MEMBER | Description: Deleting a site member's contact isn't allowed.


```

### Examples

### Delete contacts by filter
Asynchronously deletes all contacts matching a filter. Returns a job ID to poll for status.

```curl
curl -X POST \
'https://www.wixapis.com/contacts/v5/bulk/contacts/delete-by-filter' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "filter": {
    "name.last": "Reyes"
  }
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.crm.contactsV5.bulkDeleteContactsByFilter(options)
 Description: Deletes multiple contacts that match the provided filter. Works asynchronously.  All contacts that meet the specified `filter` and `search` criteria are deleted. The request must contain a `filter` value, a `search` value, or both. An empty `filter` (`{}`) without a `search` value matches all contacts, so all of the site's contacts are deleted. To preview which contacts match before deleting, call [Search Contacts](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/contacts-v5/search-contacts.md) with the same criteria.  To check the status of the bulk deletion, pass the returned `jobId` to [Get Async Job](https://dev.wix.com/docs/api-reference/business-management/async-job/get-async-job.md).  Deleted contacts are moved to the trash bin and can be restored within 90 days by calling [Restore Contact From Trash Bin](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/contacts-v5/restore-contact-from-trash-bin.md) or [Bulk Restore Contacts From Trash Bin](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/contacts-v5/bulk-restore-contacts-from-trash-bin.md).  Individual contacts can fail during processing. These failures appear in the job's results with one of the following error codes: - `CANNOT_DELETE_SITE_MEMBERS`: Contact is a site member and can't be deleted. The site member must be deleted first. - `CANNOT_DELETE_CONTACT_WITH_BILLING_SUBSCRIPTION`: Contact has an active billing subscription and can't be deleted. - `CANNOT_DELETE_WIX_USERS_MEMBER`: Site member can't be deleted because it's the owner or a contributor. - `FAILED_DELETE_CONTACT_AFTER_MEMBER_DELETION`: Site member was deleted, but the contact was not. - `FAILED_DELETE_CONTACT`: Contact couldn't be deleted.
 Method parameters:
   param name: options | type: BulkDeleteContactsByFilterOptions  none  
        - name: filter | type: object | description: Filter object. An empty filter (`{}`) matches all contacts.  Example: `{ "filter": { "name.last": "Smith" } }`  
        - name: search | type: SearchDetails | description: Free text to match in searchable fields.  
           - name: mode | type: Mode | description: How separate search terms in `expression` are combined.  
                 - enum:
                 -     OR: Any of the search terms must be present.
                 -     AND: All search terms must be present.
           - name: expression | type: string | description: Search term or expression.  | validation: maxLength 100
           - name: fields | type: array<string> | description: Fields to search in. If empty, searches all searchable fields. Use dot notation to specify the JSON path.  | validation: maxItems 20, maxLength 200
           - name: fuzzy | type: boolean | description: Whether to use fuzzy search, which allows typos using a managed proximity algorithm.  
        - name: deleteMembers | type: boolean | description: Whether to delete the associated site member for any contact that's a site member. If `true`, the site member is also deleted.  Default: `false`  
 Return type: PROMISE<BulkDeleteContactsByFilterResponse>
  - name: jobId | type: string | description: Job GUID. Pass this GUID to [Get Async Job](https://dev.wix.com/docs/api-reference/business-management/async-job/get-async-job.md) to retrieve the status of the asynchronous operation.  | validation: format GUID

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: MISSING_FILTER_AND_SEARCH | Description: The request must contain a `filter` value, a `search` value, or both.
   HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: UNAUTHORIZED_DELETE_MEMBER | Description: Deleting a site member's contact isn't allowed.


```

### Examples

### Delete contacts by filter
```javascript
import { contactsV5 } from "@wix/crm";

const filter = {
  "name.last": "Reyes",
};

async function bulkDeleteContactsByFilter() {
  const response = await contactsV5.bulkDeleteContactsByFilter(filter);
}

/* Promise resolves to:
 * {
 *   "jobId": "84daf9f8-f55f-434b-8fe7-945d84fd1578"
 * }
 */

```

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

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


async function bulkDeleteContactsByFilter(options) {
  const response = await myWixClient.contactsV5.bulkDeleteContactsByFilter(options);
};
```

---