> 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

# 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. 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. 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
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  filter
 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.  Example: `{ "filter": { "name.last": "Smith" } }` | required: true 
   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: 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(filter, 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. 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.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  filter
 Method parameters: 
   param name: filter | type: object | description: Filter object.  Example: `{ "filter": { "name.last": "Smith" } }` | required: true 
   param name: options | type: BulkDeleteContactsByFilterOptions  none  
        - 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: 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-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 { 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(filter,options) {
  const response = await myWixClient.contactsV5.bulkDeleteContactsByFilter(filter,options);
};
```

---