> 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

# UpdateConsentPolicy

# Package: siteProperties

# Namespace: SitePropertiesV4

# Method link: https://dev.wix.com/docs/api-reference/business-management/site-properties/properties/update-consent-policy?apiView=SDK.md

## Permission Scopes:
Manage Consent Policy: SCOPE.DC-SITEPROP.MANAGE-PROPERTIES

## Introduction

Updates a site's default consent policy.

Read more about [Consent Apps](https://dev.wix.com/docs/build-apps/launch-your-app/legal-and-security/about-consent-apps.md#about-consent-apps).

---

## REST API

### Schema

```
 Method: updateConsentPolicy
 Description: Updates a site's default consent policy.  Read more about [Consent Apps](https://dev.wix.com/docs/build-apps/launch-your-app/legal-and-security/about-consent-apps.md#about-consent-apps).
 URL: https://www.wixapis.com/site-properties/v4/properties/policy
 Method: POST
 Method parameters:
   param name: consentPolicy | type: ConsentPolicy    
        - name: essential | type: boolean | description: Whether the site uses cookies that are essential to site operation. Always `true`.  
        - name: functional | type: boolean | description: Whether the site uses cookies that affect site performance and other functional measurements.  
        - name: analytics | type: boolean | description: Whether the site uses cookies that collect analytics about how the site is used (in order to improve it).  
        - name: advertising | type: boolean | description: Whether the site uses cookies that collect information allowing better customization of the experience for a current visitor.  
        - name: dataToThirdParty | type: boolean | description: CCPA compliance flag.  
 Return type: UpdateConsentPolicyResponse
  EMPTY-OBJECT {}

 Possible Errors:
   HTTP Code: 401 | Status Code: UNAUTHENTICATED | Application Code: META_SITE_NOT_FOUND | Description: Couldn't find the site.
   HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: PERMISSION_DENIED | Description: The [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities.md) used to call the method doesn't have the required permissions.


```

### Examples

### Update a site's default consent policy
```curl
curl -X POST \
'https://www.wixapis.com/site-properties/v4/properties/policy' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "consentPolicy": {
    "essential": true,
    "functional": true,
    "analytics": true,
    "advertising": false,
    "dataToThirdParty": false
  }
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.businessTools.siteProperties.updateConsentPolicy(consentPolicy)
 Description: Updates a site's default consent policy.  Read more about [Consent Apps](https://dev.wix.com/docs/build-apps/launch-your-app/legal-and-security/about-consent-apps.md#about-consent-apps).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  consentPolicy
 Method parameters: 
   param name: consentPolicy | type: ConsentPolicy   | required: true 
        - name: essential | type: boolean | description: Whether the site uses cookies that are essential to site operation. Always `true`.  
        - name: functional | type: boolean | description: Whether the site uses cookies that affect site performance and other functional measurements.  
        - name: analytics | type: boolean | description: Whether the site uses cookies that collect analytics about how the site is used (in order to improve it).  
        - name: advertising | type: boolean | description: Whether the site uses cookies that collect information allowing better customization of the experience for a current visitor.  
        - name: dataToThirdParty | type: boolean | description: CCPA compliance flag.  
 Return type: PROMISE<UpdateConsentPolicyResponse>
  EMPTY-OBJECT {}

 Possible Errors:
   HTTP Code: 401 | Status Code: UNAUTHENTICATED | Application Code: META_SITE_NOT_FOUND | Description: Couldn't find the site.
   HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: PERMISSION_DENIED | Description: The [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities.md) used to call the method doesn't have the required permissions.


```

### Examples

### updateConsentPolicy - Practical Example (with $w)
This code is an example of a webpage where users can update the consent policy, using checkboxes to indicate the values. This page is only accessible to managers.

```javascript
/**************************************************
 * Backend code - update-consent-policy.web.js/ts *
 *************************************************/
import { Permissions, webMethod } from '@wix/web-methods';
import { siteProperties } from '@wix/business-tools';
import { auth } from '@wix/essentials';

export const myUpdateConsentPolicyFunction = webMethod(Permissions.Anyone, async (consentPolicy) => {
  try {
    const elevatedUpdateConsentPolicy = auth.elevate(siteProperties.updateConsentPolicy);
    await elevatedUpdateConsentPolicy(consentPolicy);

    console.log('Success! Updated policy');
    return true;
  } catch (error) {
    console.error(error);
    throw new Error(error);
  }
});
  
  
/*************
 * Page code *
 ************/

import { myUpdateConsentPolicyFunction } from 'backend/update-consent-policy.web';

$w.onReady(() => {
  $w('#submit').onClick(async () => {
    const updatedPolicy = {
      advertising: $w('#advertising').checked,
      analytics: $w('#analytics').checked,
      dataToThirdParty: $w('#dataToThirdParty').checked,
      essential: $w('#essential').checked,
      functional: $w('#functional').checked
    }
    const isUpdated = await myUpdateConsentPolicyFunction(updatedPolicy);

    if (isUpdated) {
        console.log('Consent policy successfully updated');
        $w('#successfulUpdateMsg').show();
        setTimeout(() => {
          $w('#successfulUpdateMsg').hide();  
        }, 10000);
      }
  });
});

```

### Update Consent Policy (with elevated permissions) @description:
```javascript
import { siteProperties } from '@wix/business-tools';
import { auth } from '@wix/essentials';

/* Sample objectArg value:
 * {
 *   advertising: true,
 *   analytics: true,
 *   dataToThirdParty: true,
 *   essential: true,
 *   functional: true
 * }
 */

export async function myUpdateConsentPolicyFunction(consentPolicy) {
  try {
    const elevatedUpdateConsentPolicy = auth.elevate(siteProperties.updateConsentPolicy);
    await elevatedUpdateConsentPolicy(consentPolicy);

    console.log('Success! Updated policy');
    return true;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to void */

```

### Update Consent Policy @description:
```javascript
import { siteProperties } from '@wix/business-tools';

/* Sample objectArg value:
 * {
 *   advertising: true,
 *   analytics: true,
 *   dataToThirdParty: true,
 *   essential: true,
 *   functional: true
 * }
 */

export async function myUpdateConsentPolicyFunction(consentPolicy) {
  try {
    await siteProperties.updateConsentPolicy(consentPolicy);

    console.log('Success! Updated policy');
    return true;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to void */

```

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

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


async function updateConsentPolicy(consentPolicy) {
  const response = await myWixClient.siteProperties.updateConsentPolicy(consentPolicy);
};
```

---