> 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 # Package: communication # Namespace: emailSubscriptions # Webhook link: https://dev.wix.com/docs/api-reference/crm/communication/email-subscriptions/emailsubscription-email-subscription-changed.md ## Introduction # Webhook Permissions Scopes IDs: Manage Email Subscriptions: SCOPE.DC-MANAGE.EMAIL-SUBSCRIPTIONS --- ## REST API ### Schema ``` Webhook: Emailsubscription Email Subscription Changed Description: Payload: EmailSubscriptionChanged - name: subscription | type: EmailSubscription | description: Email subscription that changed. - name: id | type: string | description: Email subscription GUID. - name: email | type: string | description: Email address. - name: subscriptionStatus | type: Status | description: Indicates the recipient's opt-in or opt-out status for marketing emails. Default: `NOT_SET`. - enum: - UNKNOWN: Undefined status. - NOT_SET: No status specified. This is the default, initial value before any info about the email address is known. - PENDING: Subscription confirmation was requested, but recipient hasn't confirmed yet. - SUBSCRIBED: Recipient has opted in to marketing emails. - UNSUBSCRIBED: Recipient has opted out of marketing emails. - name: deliverabilityStatus | type: Status | description: Indicates last reported status of sent emails. Default: `NOT_SET`. - enum: - NOT_SET: No status specified. This is the initial default value before any info about the email address is known. - VALID: Emails to this email address are being delivered successfully. - BOUNCED: The last email to the recipient bounced or was rejected. - SPAM_COMPLAINT: The recipient registered a spam complaint with their email provider. - INACTIVE: Multiple campaigns have been delivered to this address without any engagement from the recipient. (No emails were opened and no content was clicked.) This status might impact subsequent emails sent to this address. - name: createdDate | type: string | description: Date and time the email subscription was created. - name: updatedDate | type: string | description: Date and time the email subscription was last updated. ``` ### Examples ```curl { "subscription": { "id": "9c130f52-31c4-11ed-a261-0242ac120002", "email": "someone-else@theircompany.com", "subscriptionStatus": "UNSUBSCRIBED", "deliverabilityStatus": "VALID", "createdDate" : "2019-10-30T17:22:10.299Z", "updatedDate" : "2019-11-13T20:14:49.458Z" } } ``` --- ## JavaScript SDK ### Schema ``` Webhook: onEmailsubscriptionEmailSubscriptionChanged Description: Payload: EmailsubscriptionEmailSubscriptionChangedEnvelope - name: data | type: EmailSubscriptionChanged | description: none - name: subscription | type: EmailSubscription | description: Email subscription that changed. - name: _id | type: string | description: Email subscription GUID. - name: email | type: string | description: Email address. - name: subscriptionStatus | type: Status | description: Indicates the recipient's opt-in or opt-out status for marketing emails. Default: `NOT_SET`. - enum: - UNKNOWN: Undefined status. - NOT_SET: No status specified. This is the default, initial value before any info about the email address is known. - PENDING: Subscription confirmation was requested, but recipient hasn't confirmed yet. - SUBSCRIBED: Recipient has opted in to marketing emails. - UNSUBSCRIBED: Recipient has opted out of marketing emails. - name: deliverabilityStatus | type: Status | description: Indicates last reported status of sent emails. Default: `NOT_SET`. - enum: - NOT_SET: No status specified. This is the initial default value before any info about the email address is known. - VALID: Emails to this email address are being delivered successfully. - BOUNCED: The last email to the recipient bounced or was rejected. - SPAM_COMPLAINT: The recipient registered a spam complaint with their email provider. - INACTIVE: Multiple campaigns have been delivered to this address without any engagement from the recipient. (No emails were opened and no content was clicked.) This status might impact subsequent emails sent to this address. - name: _createdDate | type: Date | description: Date and time the email subscription was created. - name: _updatedDate | type: Date | description: Date and time the email subscription was last updated. - name: metadata | type: BaseEventMetadata | description: none - name: instanceId | type: string | description: App instance GUID. - name: eventType | type: string | description: Event type. - name: identity | type: IdentificationData | description: The identification type and identity data. - ONE-OF: - name: anonymousVisitorId | type: string | description: GUID of a site visitor that has not logged in to the site. - name: memberId | type: string | description: GUID of a site visitor that has logged in to the site. - name: wixUserId | type: string | description: GUID of a Wix user (site owner, contributor, etc.). - name: appId | type: string | description: GUID of an app. - name: identityType | type: WebhookIdentityType | description: - enum: UNKNOWN, ANONYMOUS_VISITOR, MEMBER, WIX_USER, APP - name: accountInfo | type: AccountInfo | description: Details related to the account - name: accountId | type: string | description: GUID of the Wix account associated with the event. - name: parentAccountId | type: string | description: GUID of the parent Wix account. Only included when accountId belongs to a child account. - name: siteId | type: string | description: GUID of the Wix site associated with the event. Only included when the event is tied to a specific site. ``` ### Examples ```javascript import { emailSubscriptions } from '@wix/email-subscriptions'; emailSubscriptions.onEmailsubscriptionEmailSubscriptionChanged((event) => { // handle your event here }); ``` ```javascript import { createClient, AppStrategy } from '@wix/sdk'; import { emailSubscriptions } from '@wix/email-subscriptions'; const wixClient = createClient({ auth: AppStrategy({ appId: 'MY-APP-ID', publicKey: 'YOUR_APP_PUBLIC_KEY', }), modules: { emailSubscriptions, }, }); wixClient.emailSubscriptions.onEmailsubscriptionEmailSubscriptionChanged((event) => { // handle your event here }); ``` ---