> 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

# BulkUpdatePhoneCountryCodeByFilter

# Package: contacts

# Namespace: Contacts

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

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

## Introduction

Adds a country code to the main phone of multiple contacts that match the provided filter. Works asynchronously.

A contact's main phone is changed only if adding the country code produces a valid phone number. Otherwise, the contact is left unchanged.

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

---

## REST API

### Schema

```
 Method: bulkUpdatePhoneCountryCodeByFilter
 Description: Adds a country code to the main phone of multiple contacts that match the provided filter. Works asynchronously.  A contact's main phone is changed only if adding the country code produces a valid phone number. Otherwise, the contact is left unchanged.  To check the status of the bulk update, pass the returned `jobId` to [Get Async Job](https://dev.wix.com/docs/api-reference/business-management/async-job/get-async-job.md).
 URL: https://www.wixapis.com/contacts/v5/bulk/contacts/update-phone-country-code-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:  countryCode
 Method parameters: 
   param name: countryCode | type: countryCode | description: [ISO-3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code to apply.  Applied only to contacts whose phone number isn't already in [ITU E.164 international](https://www.itu.int/rec/T-REC-E.164/) format. If the phone number still can't be converted to E.164 format after applying the country code, that contact fails with `PHONE_CANNOT_BE_FIXED_WITH_COUNTRY_CODE`. | required: true | validation: format COUNTRY
   param name: filter | type: filter | description: A filter for the contacts that the country code will be applied to.  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: BulkUpdatePhoneCountryCodeByFilterResponse
  - 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


```

### Examples

### Update phone country code by filter
Asynchronously adds a country code to the main phone of 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/update-phone-country-code-by-filter' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "filter": {
    "company.name": "ExampleCo"
  },
  "countryCode": "US"
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.crm.contactsV5.bulkUpdatePhoneCountryCodeByFilter(options)
 Description: Adds a country code to the main phone of multiple contacts that match the provided filter. Works asynchronously.  A contact's main phone is changed only if adding the country code produces a valid phone number. Otherwise, the contact is left unchanged.  To check the status of the bulk update, pass the returned `jobId` to [Get Async Job](https://dev.wix.com/docs/api-reference/business-management/async-job/get-async-job.md).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  options.countryCode, options
 Method parameters: 
   param name: options | type: BulkUpdatePhoneCountryCodeByFilterOptions  none | required: true 
        - name: filter | type: object | description: A filter for the contacts that the country code will be applied to.  Example: `{ "filter": { "name.last": "Smith" } }`  
        - name: search | type: SearchDetails | description: Free text to match in searchable fields for the contacts that the country code will be applied to.  
           - 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: countryCode | type: string | description: [ISO-3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code to apply.  Applied only to contacts whose phone number isn't already in [ITU E.164 international](https://www.itu.int/rec/T-REC-E.164/) format. If the phone number still can't be converted to E.164 format after applying the country code, that contact fails with `PHONE_CANNOT_BE_FIXED_WITH_COUNTRY_CODE`. | required: true | validation: format COUNTRY
 Return type: PROMISE<BulkUpdatePhoneCountryCodeByFilterResponse>
  - 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


```

### Examples

### Update phone country code by filter
```javascript
import { contactsV5 } from "@wix/crm";

const options = {
  countryCode: "US",
  filter: { "company.name": "ExampleCo" },
};

async function bulkUpdatePhoneCountryCodeByFilter() {
  const response = await contactsV5.bulkUpdatePhoneCountryCodeByFilter(options);
}

/* Promise resolves to:
 * {
 *   "jobId": "bb8a71b5-42d7-4580-9f27-6282e8363ad4"
 * }
 */

```

### bulkUpdatePhoneCountryCodeByFilter (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 bulkUpdatePhoneCountryCodeByFilter(options) {
  const response = await myWixClient.contactsV5.bulkUpdatePhoneCountryCodeByFilter(options);
};
```

---