> 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 # 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 - name: dataCollectionId | type: string | description: GUID of the data collection to share. - 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. - name: dataCollectionId | type: string | description: GUID of the data collection to share. - 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. - name: updatedDate | type: string | description: Date and time the data sharing policy was last updated. 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: ' \ -d '{ "dataSharingPolicy": { "dataItemsFilter": { "category": { "$ne": "private" } } } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.collectionManagement.DataCollectionSharingService.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 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. - 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 - name: _id | type: string | description: Data sharing policy GUID. - name: dataCollectionId | type: string | description: GUID of the data collection to share. - 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. - name: _updatedDate | type: Date | description: Date and time the data sharing policy was last updated. 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-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 { 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); }; ``` ---