> 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

# UpdateMarketingConsent

# Package: marketing

# Namespace: MarketingConsentService

# Method link: https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-consent/update-marketing-consent.md

## Permission Scopes:
Manage Marketing Consents: SCOPE.DC-MARKETING.CONSENT-MANAGE

## Introduction

Updates a marketing consent.
Required fields:
- `details.type`.
- `details.email` OR `details.phone`.
- `state`.

When a marketing consent's `state` is `PENDING` or `CONFIRMED`, the `info.lastConfirmationActivity` field is required.
When a marketing consent's `state` is `REVOKED`, the `info.lastRevokeActivity` field is required.

>**Note:** For existing marketing consents with `{"type": "EMAIL"}`, you can't update the `state` to `UNKNOWN_STATE`. Trying to do so maintains the current state. However, you can create a new marketing consent and set the `state` to `UNKNOWN_STATE`. Note that you can't create more than a single consent per email or phone number.

---

## REST API

### Schema

```
 Method: updateMarketingConsent
 Description: Updates a marketing consent. Required fields: - `details.type`. - `details.email` OR `details.phone`. - `state`.  When a marketing consent's `state` is `PENDING` or `CONFIRMED`, the `info.lastConfirmationActivity` field is required. When a marketing consent's `state` is `REVOKED`, the `info.lastRevokeActivity` field is required.  >**Note:** For existing marketing consents with `{"type": "EMAIL"}`, you can't update the `state` to `UNKNOWN_STATE`. Trying to do so maintains the current state. However, you can create a new marketing consent and set the `state` to `UNKNOWN_STATE`. Note that you can't create more than a single consent per email or phone number.
 URL: https://www.wixapis.com/marketing-consent/v1/marketing-consent/{marketingConsent.id}
 Method: PATCH
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  mask, marketingConsent.details, marketingConsent.id
 Method parameters: 
   param name: marketingConsent | type: MarketingConsent    
        - name: id | type: string | description: Marketing consent GUID. | required: true | read-only: true | validation: format GUID, immutable
        - name: details | type: MarketingConsentDetails | description: Marketing consent communication details. | required: true 
           - ONE-OF: 
              - name: email | type: string | description: Email address used for the marketing consent.  | validation: format EMAIL
              - name: phone | type: string | description: Phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format used for the SMS marketing consent.  | validation: format PHONE
           - name: type | type: MarketingConsentDetailsIdentifierType | description: The communication channel of the marketing consent.  
                 - enum: UNKNOWN_TYPE, EMAIL, PHONE
        - name: state | type: MarketingConsentState | description: Marketing consent state.  Default: `UNKNOWN_STATE`.  
             - enum:
             -     UNKNOWN_STATE: State of the marketing consent is unknown.
             -     NEVER_CONFIRMED: The site visitor never confirmed to receive marketing consents.
             -     REVOKED: The marketing consent has been removed, for example, when a site visitor unsubscribes from a newsletter.
             -     PENDING: The marketing consent is pending confirmation. Relevant only for `{"optInLevel": "DOUBLE_CONFIRMATION"}`.
             -     CONFIRMED: The site visitor has confirmed their marketing consent.
        - name: lastConfirmationActivity | type: LastConfirmationActivity | description: Last confirmation activity of the marketing consent.  
           - name: source | type: Source | description: Source of the given consent (how the site visitor signed up).  
                 - enum: IN_PERSON, FORM, LINK_CONFIRMATION, EMAIL_SERVICE, WIX_USERS, OTHER
           - name: description | type: string | description: Consent description.  | validation: minLength 1, maxLength 200
           - name: updatedDate | type: string | description: Date and time the consent was updated.  | validation: format date-time
           - name: optInLevel | type: OptInLevel | description: Consent opt in level, either single or double confirmation.  
                 - enum: UNKNOWN_OPT_IN_LEVEL, SINGLE_CONFIRMATION, DOUBLE_CONFIRMATION
        - name: lastRevokeActivity | type: LastRevokeActivity | description: Last revoke activity of the marketing consent.  
           - name: source | type: Source | description: Source of the given revoke (how the visitor signed up).  
                 - enum: IN_PERSON, FORM, REVOKE_LINK, WIX_USERS, OTHER
           - name: description | type: string | description: Details about the revoke, if relevant.  | validation: minLength 1, maxLength 200
           - name: updatedDate | type: string | description: Date and time the consent was updated.  | validation: format date-time
        - name: extendedFields | type: ExtendedFields | description: Additional fields.  
           - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
   param name: mask | type: mask | description: Explicit list of fields to update | required: true 
 Return type: UpdateMarketingConsentResponse
  - name: marketingConsent | type: MarketingConsent | description: Updated marketing consent.  
     - name: id | type: string | description: Marketing consent GUID.  | read-only: true | validation: format GUID, immutable
     - name: revision | type: string | description: Revision number.  | read-only: true | validation: format int64
     - name: details | type: MarketingConsentDetails | description: Marketing consent communication details.  
        - ONE-OF: 
           - name: email | type: string | description: Email address used for the marketing consent.  | validation: format EMAIL
           - name: phone | type: string | description: Phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format used for the SMS marketing consent.  | validation: format PHONE
        - name: type | type: MarketingConsentDetailsIdentifierType | description: The communication channel of the marketing consent.  
             - enum: UNKNOWN_TYPE, EMAIL, PHONE
     - name: state | type: MarketingConsentState | description: Marketing consent state.  Default: `UNKNOWN_STATE`.  
         - enum:
         -     UNKNOWN_STATE: State of the marketing consent is unknown.
         -     NEVER_CONFIRMED: The site visitor never confirmed to receive marketing consents.
         -     REVOKED: The marketing consent has been removed, for example, when a site visitor unsubscribes from a newsletter.
         -     PENDING: The marketing consent is pending confirmation. Relevant only for `{"optInLevel": "DOUBLE_CONFIRMATION"}`.
         -     CONFIRMED: The site visitor has confirmed their marketing consent.
     - name: createdDate | type: string | description: Date and time the marketing consent was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the marketing consent was updated.  | read-only: true | validation: format date-time
     - name: lastConfirmationActivity | type: LastConfirmationActivity | description: Last confirmation activity of the marketing consent.  
        - name: source | type: Source | description: Source of the given consent (how the site visitor signed up).  
             - enum: IN_PERSON, FORM, LINK_CONFIRMATION, EMAIL_SERVICE, WIX_USERS, OTHER
        - name: description | type: string | description: Consent description.  | validation: minLength 1, maxLength 200
        - name: updatedDate | type: string | description: Date and time the consent was updated.  | validation: format date-time
        - name: optInLevel | type: OptInLevel | description: Consent opt in level, either single or double confirmation.  
             - enum: UNKNOWN_OPT_IN_LEVEL, SINGLE_CONFIRMATION, DOUBLE_CONFIRMATION
     - name: lastRevokeActivity | type: LastRevokeActivity | description: Last revoke activity of the marketing consent.  
        - name: source | type: Source | description: Source of the given revoke (how the visitor signed up).  
             - enum: IN_PERSON, FORM, REVOKE_LINK, WIX_USERS, OTHER
        - name: description | type: string | description: Details about the revoke, if relevant.  | validation: minLength 1, maxLength 200
        - name: updatedDate | type: string | description: Date and time the consent was updated.  | validation: format date-time
     - name: extendedFields | type: ExtendedFields | description: Additional fields.  
        - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
  - name: link | type: Link | description: Marketing consent confirmation or cancelation link.  
     - name: type | type: LinkType | description: Link type.  
         - enum: UNKNOWN_LINK_TYPE, CONFIRMATION, REVOKE_CONFIRMATION
     - name: url | type: string | description: The link's URL.  | validation: format WEB_URL


```

### Examples

### Update Marketing Consent
```curl
curl -X PATCH \
  'https://www.wixapis.com/marketing-consent/v1/marketing-consent/aa8a62f5-9a79-4b21-b1a4-5c835c08d937' \
  -H 'Authorization: <AUTH>' \
  -d '{
    "marketingConsent": {
      "details": {
        "type": "EMAIL",
        "email": "mytest@test.com"
      },
      "state": "REVOKED",
      "revision": "3",
      "lastConfirmationActivity": {
        "source": "IN_PERSON"
      }
    },
    "mask": {
      "paths": [
        "state",
        "lastConfirmationActivity.source"
      ]
    }
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.marketing.marketingConsent.updateMarketingConsent(_id, options)
 Description: Updates a marketing consent. Required fields: - `details.type`. - `details.email` OR `details.phone`. - `state`.  When a marketing consent's `state` is `PENDING` or `CONFIRMED`, the `info.lastConfirmationActivity` field is required. When a marketing consent's `state` is `REVOKED`, the `info.lastRevokeActivity` field is required.  >**Note:** For existing marketing consents with `{"type": "EMAIL"}`, you can't update the `state` to `UNKNOWN_STATE`. Trying to do so maintains the current state. However, you can create a new marketing consent and set the `state` to `UNKNOWN_STATE`. Note that you can't create more than a single consent per email or phone number.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  options.mask, options.marketingConsent.details, _id, options
 Method parameters: 
   param name: _id | type: string | description: Marketing consent GUID. | required: true | validation: format GUID, immutable
   param name: options | type: UpdateMarketingConsentOptions  none | required: true 
        - name: marketingConsent | type: MarketingConsent | description: Marketing consent to update.  
           - name: details | type: MarketingConsentDetails | description: Marketing consent communication details. | required: true 
              - ONE-OF: 
                 - name: email | type: string | description: Email address used for the marketing consent.  | validation: format EMAIL
                 - name: phone | type: string | description: Phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format used for the SMS marketing consent.  | validation: format PHONE
              - name: type | type: MarketingConsentDetailsIdentifierType | description: The communication channel of the marketing consent.  
                     - enum: UNKNOWN_TYPE, EMAIL, PHONE
           - name: state | type: MarketingConsentState | description: Marketing consent state.  Default: `UNKNOWN_STATE`.  
                 - enum:
                 -     UNKNOWN_STATE: State of the marketing consent is unknown.
                 -     NEVER_CONFIRMED: The site visitor never confirmed to receive marketing consents.
                 -     REVOKED: The marketing consent has been removed, for example, when a site visitor unsubscribes from a newsletter.
                 -     PENDING: The marketing consent is pending confirmation. Relevant only for `{"optInLevel": "DOUBLE_CONFIRMATION"}`.
                 -     CONFIRMED: The site visitor has confirmed their marketing consent.
           - name: lastConfirmationActivity | type: LastConfirmationActivity | description: Last confirmation activity of the marketing consent.  
              - name: source | type: Source | description: Source of the given consent (how the site visitor signed up).  
                     - enum: IN_PERSON, FORM, LINK_CONFIRMATION, EMAIL_SERVICE, WIX_USERS, OTHER
              - name: description | type: string | description: Consent description.  | validation: minLength 1, maxLength 200
              - name: _updatedDate | type: Date | description: Date and time the consent was updated.  
              - name: optInLevel | type: OptInLevel | description: Consent opt in level, either single or double confirmation.  
                     - enum: UNKNOWN_OPT_IN_LEVEL, SINGLE_CONFIRMATION, DOUBLE_CONFIRMATION
           - name: lastRevokeActivity | type: LastRevokeActivity | description: Last revoke activity of the marketing consent.  
              - name: source | type: Source | description: Source of the given revoke (how the visitor signed up).  
                     - enum: IN_PERSON, FORM, REVOKE_LINK, WIX_USERS, OTHER
              - name: description | type: string | description: Details about the revoke, if relevant.  | validation: minLength 1, maxLength 200
              - name: _updatedDate | type: Date | description: Date and time the consent was updated.  
           - name: extendedFields | type: ExtendedFields | description: Additional fields.  
              - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
        - name: mask | type: array<string> | description: Explicit list of fields to update | required: true 
 Return type: PROMISE<MarketingConsent>
  - name: _id | type: string | description: Marketing consent GUID.  | read-only: true | validation: format GUID, immutable
  - name: revision | type: string | description: Revision number.  | read-only: true | validation: format int64
  - name: details | type: MarketingConsentDetails | description: Marketing consent communication details.  
     - ONE-OF: 
        - name: email | type: string | description: Email address used for the marketing consent.  | validation: format EMAIL
        - name: phone | type: string | description: Phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format used for the SMS marketing consent.  | validation: format PHONE
     - name: type | type: MarketingConsentDetailsIdentifierType | description: The communication channel of the marketing consent.  
         - enum: UNKNOWN_TYPE, EMAIL, PHONE
  - name: state | type: MarketingConsentState | description: Marketing consent state.  Default: `UNKNOWN_STATE`.  
     - enum:
     -     UNKNOWN_STATE: State of the marketing consent is unknown.
     -     NEVER_CONFIRMED: The site visitor never confirmed to receive marketing consents.
     -     REVOKED: The marketing consent has been removed, for example, when a site visitor unsubscribes from a newsletter.
     -     PENDING: The marketing consent is pending confirmation. Relevant only for `{"optInLevel": "DOUBLE_CONFIRMATION"}`.
     -     CONFIRMED: The site visitor has confirmed their marketing consent.
  - name: _createdDate | type: Date | description: Date and time the marketing consent was created.  | read-only: true 
  - name: _updatedDate | type: Date | description: Date and time the marketing consent was updated.  | read-only: true 
  - name: lastConfirmationActivity | type: LastConfirmationActivity | description: Last confirmation activity of the marketing consent.  
     - name: source | type: Source | description: Source of the given consent (how the site visitor signed up).  
         - enum: IN_PERSON, FORM, LINK_CONFIRMATION, EMAIL_SERVICE, WIX_USERS, OTHER
     - name: description | type: string | description: Consent description.  | validation: minLength 1, maxLength 200
     - name: _updatedDate | type: Date | description: Date and time the consent was updated.  
     - name: optInLevel | type: OptInLevel | description: Consent opt in level, either single or double confirmation.  
         - enum: UNKNOWN_OPT_IN_LEVEL, SINGLE_CONFIRMATION, DOUBLE_CONFIRMATION
  - name: lastRevokeActivity | type: LastRevokeActivity | description: Last revoke activity of the marketing consent.  
     - name: source | type: Source | description: Source of the given revoke (how the visitor signed up).  
         - enum: IN_PERSON, FORM, REVOKE_LINK, WIX_USERS, OTHER
     - name: description | type: string | description: Details about the revoke, if relevant.  | validation: minLength 1, maxLength 200
     - name: _updatedDate | type: Date | description: Date and time the consent was updated.  
  - name: extendedFields | type: ExtendedFields | description: Additional fields.  
     - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map


```

### Examples

### updateMarketingConsent
```javascript
import { marketingConsent } from '@wix/marketing';

async function updateMarketingConsent(_id,options) {
  const response = await marketingConsent.updateMarketingConsent(_id,options);
};
```

### updateMarketingConsent (with elevated permissions)
```javascript
import { marketingConsent } from '@wix/marketing';
import { auth } from '@wix/essentials';

async function myUpdateMarketingConsentMethod(_id,options) {
  const elevatedUpdateMarketingConsent = auth.elevate(marketingConsent.updateMarketingConsent);
  const response = await elevatedUpdateMarketingConsent(_id,options);
}
```

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

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


async function updateMarketingConsent(_id,options) {
  const response = await myWixClient.marketingConsent.updateMarketingConsent(_id,options);
};
```

---