> 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

# UpdateDataSharingPolicy

# Package: collectionManagement

# Namespace: DataCollectionSharingService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-sharing/update-data-sharing-policy.md

## Permission Scopes:
Manage Data Collection Sharing: SCOPE.DATA.MANAGE_COLLECTION_SHARING

## Introduction

Updates an existing data sharing policy.

You can only update the `dataItemsFilter` field to change which items from the collection are shared.
You can't change which collection is shared. If you want to share a different collection, create a new data sharing policy

Any updates to the policy automatically apply to all sites connected using this policy.

---

## REST API

### Schema

```
 Method: updateDataSharingPolicy
 Description: Updates an existing data sharing policy.  You can only update the `dataItemsFilter` field to change which items from the collection are shared. You can't change which collection is shared. If you want to share a different collection, create a new data sharing policy  Any updates to the policy automatically apply to all sites connected using this policy.
 URL: https://www.wixapis.com/data/v1/data-collection-sharing/policies/{dataSharingPolicy.id}
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  dataSharingPolicy, dataSharingPolicy.id
 Method parameters: 
   param name: dataSharingPolicy | type: DataSharingPolicy | description: A data sharing policy defines how a data collection is shared between sites in the same Wix account.  The policy specifies which collection to share, optional filtering rules to control which items are accessible, and serves as the access credential for other sites to connect to the shared collection. Multiple policies can be created for the same collection with different filtering rules or access patterns. | required: true 
        - name: id | type: string | description: Data sharing policy GUID. | required: true | read-only: true | validation: format GUID
        - name: dataCollectionId | type: string | description: GUID of the data collection to share.  | validation: maxLength 255, immutable
        - name: dataItemsFilter | type: object | description: Filter to restrict which items from the collection are shared.  Use [API Query Language syntax](https://dev.wix.com/api/rest/getting-started/api-query-language) to define filtering rules. If not specified, all items in the collection are shared.  
 Return type: UpdateDataSharingPolicyResponse
  - name: dataSharingPolicy | type: DataSharingPolicy | description: Updated data sharing policy.  
     - name: id | type: string | description: Data sharing policy GUID.  | read-only: true | validation: format GUID
     - name: dataCollectionId | type: string | description: GUID of the data collection to share.  | validation: maxLength 255, immutable
     - name: dataItemsFilter | type: object | description: Filter to restrict which items from the collection are shared.  Use [API Query Language syntax](https://dev.wix.com/api/rest/getting-started/api-query-language) to define filtering rules. If not specified, all items in the collection are shared.  
     - name: createdDate | type: string | description: Date and time the data sharing policy was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the data sharing policy was last updated.  | read-only: true | validation: format date-time

 Possible Errors:
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: WDE0154 | Description: Data sharing policy not found. Verify the policy GUID is correct and is owned by the current site.


```

### Examples

### Update data sharing policy
```curl
curl -X POST \
	'https://wixapis.com/wix-data/v1/data-collection-sharing/policies/f6d058c0-6d5a-4ca5-b4a6-24933fce9175'  \
  -H 'Content-Type: application/json;charset=UTF-8' \
  -H 'Authorization: <AUTH>' \
  -d '{
    "dataSharingPolicy": {
			"dataItemsFilter": {
				"category": { "$ne": "private" }
			}
    }
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.data.sharing.updateDataSharingPolicy(_id, dataSharingPolicy)
 Description: Updates an existing data sharing policy.  You can only update the `dataItemsFilter` field to change which items from the collection are shared. You can't change which collection is shared. If you want to share a different collection, create a new data sharing policy  Any updates to the policy automatically apply to all sites connected using this policy.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  dataSharingPolicy, _id
 Method parameters: 
   param name: _id | type: string | description: Data sharing policy GUID. | required: true | validation: format GUID
   param name: dataSharingPolicy | type: DataSharingPolicy | description: A data sharing policy defines how a data collection is shared between sites in the same Wix account.  The policy specifies which collection to share, optional filtering rules to control which items are accessible, and serves as the access credential for other sites to connect to the shared collection. Multiple policies can be created for the same collection with different filtering rules or access patterns. | required: true 
        - name: dataCollectionId | type: string | description: GUID of the data collection to share.  | validation: maxLength 255, immutable
        - name: dataItemsFilter | type: object | description: Filter to restrict which items from the collection are shared.  Use [API Query Language syntax](https://dev.wix.com/api/rest/getting-started/api-query-language) to define filtering rules. If not specified, all items in the collection are shared.  
 Return type: PROMISE<DataSharingPolicy>
  - name: _id | type: string | description: Data sharing policy GUID.  | read-only: true | validation: format GUID
  - name: dataCollectionId | type: string | description: GUID of the data collection to share.  | validation: maxLength 255, immutable
  - name: dataItemsFilter | type: object | description: Filter to restrict which items from the collection are shared.  Use [API Query Language syntax](https://dev.wix.com/api/rest/getting-started/api-query-language) to define filtering rules. If not specified, all items in the collection are shared.  
  - name: _createdDate | type: Date | description: Date and time the data sharing policy was created.  | read-only: true 
  - name: _updatedDate | type: Date | description: Date and time the data sharing policy was last updated.  | read-only: true 

 Possible Errors:
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: WDE0154 | Description: Data sharing policy not found. Verify the policy GUID is correct and is owned by the current site.


```

### Examples

### updateDataSharingPolicy
```javascript
import { sharing } from '@wix/data';

async function updateDataSharingPolicy(_id,dataSharingPolicy) {
  const response = await sharing.updateDataSharingPolicy(_id,dataSharingPolicy);
};
```

### updateDataSharingPolicy (with elevated permissions)
```javascript
import { sharing } from '@wix/data';
import { auth } from '@wix/essentials';

async function myUpdateDataSharingPolicyMethod(_id,dataSharingPolicy) {
  const elevatedUpdateDataSharingPolicy = auth.elevate(sharing.updateDataSharingPolicy);
  const response = await elevatedUpdateDataSharingPolicy(_id,dataSharingPolicy);
}
```

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

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


async function updateDataSharingPolicy(_id,dataSharingPolicy) {
  const response = await myWixClient.sharing.updateDataSharingPolicy(_id,dataSharingPolicy);
};
```

---