> 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 # CreateMarketingConsent # Package: marketing # Namespace: MarketingConsentService # Method link: https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-consent/create-marketing-consent.md ## Permission Scopes: Manage Marketing Consents: SCOPE.DC-MARKETING.CONSENT-MANAGE ## Introduction Creates a confirmed marketing consent with a `state` of `CONFIRMED`. Required fields: - `details.type`. - `details.email` OR `details.phone`. - `lastConfirmationActivity`. To create a marketing consent with a different state, use Upsert Marketing Consent, or Bulk Upsert Marketing Consent. --- ## REST API ### Schema ``` Method: createMarketingConsent Description: Creates a confirmed marketing consent with a `state` of `CONFIRMED`. Required fields: - `details.type`. - `details.email` OR `details.phone`. - `lastConfirmationActivity`. To create a marketing consent with a different state, use Upsert Marketing Consent, or Bulk Upsert Marketing Consent. URL: https://www.wixapis.com/v1/marketing-consent Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: marketingConsent.details, marketingConsent.lastConfirmationActivity Method parameters: param name: marketingConsent | type: MarketingConsent - 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. - name: phone | type: string | description: Phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format used for the SMS marketing consent. - 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. | required: true - 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. - name: updatedDate | type: string | 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. - name: updatedDate | type: string | 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). Return type: CreateMarketingConsentResponse - name: marketingConsent | type: MarketingConsent | description: Newly created marketing consent. - name: id | type: string | description: Marketing consent GUID. - name: revision | type: string | description: Revision number. - name: details | type: MarketingConsentDetails | description: Marketing consent communication details. - ONE-OF: - name: email | type: string | description: Email address used for the marketing consent. - name: phone | type: string | description: Phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format used for the SMS marketing consent. - 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. - name: updatedDate | type: string | description: Date and time the marketing consent was updated. - 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. - name: updatedDate | type: string | 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. - name: updatedDate | type: string | 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). - name: link | type: Link | description: Marketing consent confirmation link. - name: type | type: LinkType | description: Link type. - enum: UNKNOWN_LINK_TYPE, CONFIRMATION, REVOKE_CONFIRMATION - name: url | type: string | description: The link's URL. ``` ### Examples ### Create Marketing Consent ```curl curl -X POST \ 'https://www.wixapis.com/marketing-consent/v1/marketing-consent' \ -H 'Authorization: ' \ -d '{ "marketingConsent": { "details": { "type": "PHONE", "phone": "+19172222222" }, "lastConfirmationActivity": { "source": "LINK_CONFIRMATION", "description": "Law requires double confirmation.", "optInLevel": "DOUBLE_CONFIRMATION" } } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.marketing.MarketingConsentService.createMarketingConsent(marketingConsent) Description: Creates a confirmed marketing consent with a `state` of `CONFIRMED`. Required fields: - `details.type`. - `details.email` OR `details.phone`. - `lastConfirmationActivity`. To create a marketing consent with a different state, use Upsert Marketing Consent, or Bulk Upsert Marketing Consent. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: marketingConsent.details, marketingConsent.lastConfirmationActivity, marketingConsent Method parameters: param name: marketingConsent | type: MarketingConsent | required: true - 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. - name: phone | type: string | description: Phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format used for the SMS marketing consent. - 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. | required: true - 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. - 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. - 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). Return type: PROMISE - name: _id | type: string | description: Marketing consent GUID. - name: revision | type: string | description: Revision number. - name: details | type: MarketingConsentDetails | description: Marketing consent communication details. - ONE-OF: - name: email | type: string | description: Email address used for the marketing consent. - name: phone | type: string | description: Phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format used for the SMS marketing consent. - 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. - name: _updatedDate | type: Date | description: Date and time the marketing consent was updated. - 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. - 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. - 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). ``` ### Examples ### createMarketingConsent ```javascript import { marketingConsent } from '@wix/marketing'; async function createMarketingConsent(marketingConsent) { const response = await marketingConsent.createMarketingConsent(marketingConsent); }; ``` ### createMarketingConsent (with elevated permissions) ```javascript import { marketingConsent } from '@wix/marketing'; import { auth } from '@wix/essentials'; async function myCreateMarketingConsentMethod(marketingConsent) { const elevatedCreateMarketingConsent = auth.elevate(marketingConsent.createMarketingConsent); const response = await elevatedCreateMarketingConsent(marketingConsent); } ``` ### createMarketingConsent (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 { 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 createMarketingConsent(marketingConsent) { const response = await myWixClient.marketingConsent.createMarketingConsent(marketingConsent); }; ``` ---