> 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 # BulkUpsertEmailSubscription # Package: communication # Namespace: EmailSubscriptionsService # Method link: https://dev.wix.com/docs/api-reference/crm/communication/email-subscriptions/bulk-upsert-email-subscription.md ## Permission Scopes: Manage Email Subscriptions: SCOPE.DC-MANAGE.EMAIL-SUBSCRIPTIONS ## Introduction Updates or creates multiple email subscriptions. --- ## REST API ### Schema ``` Method: bulkUpsertEmailSubscription Description: Updates or creates multiple email subscriptions. URL: https://www.wixapis.com/email-marketing/v1/email-subscriptions/bulk Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: subscriptions Method parameters: param name: subscriptions | type: array | description: List of email subscriptions to update or create. | required: true - 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. Return type: BulkUpsertEmailSubscriptionResponse - name: results | type: array | description: List of updated or created email subscriptions. - name: originalIndex | type: integer | description: Position of the requested email subscription in the bulk array. - name: emailSubscription | type: EmailSubscription | description: New or updated email subscription. - 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. - name: error | type: Error | description: Error information if the action failed. Omitted from successful actions. - name: errorCode | type: string | description: Error code. - name: message | type: string | description: Message that contains details about the error. - name: metadata | type: Metadata | description: Numbers of successful and failed actions. - name: totalSuccess | type: integer | description: Number of successful actions. - name: totalFailure | type: integer | description: Number of failed actions. ``` ### Examples ### Update or Create Multiple Subscriptions ```curl curl -X POST \ 'https://www.wixapis.com/email-marketing/v1/email-subscriptions/bulk' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ --data-binary '{ "subscriptions": [ { "email": "lead-1@new-contact.com", "subscriptionStatus": "PENDING", "deliverabilityStatus": "VALID" }, { "email": "lead-2@existing-contact.com", "subscriptionStatus": "UNSUBSCRIBED", }, { "email": "lead-3@new-contact-default-statuses.org" } ] }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.communication.EmailSubscriptionsService.bulkUpsertEmailSubscription(subscriptions) Description: Updates or creates multiple email subscriptions. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: subscriptions Method parameters: param name: subscriptions | type: array | description: List of email subscriptions to update or create. | required: true - 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. Return type: PROMISE - name: results | type: array | description: List of updated or created email subscriptions. - name: originalIndex | type: integer | description: Position of the requested email subscription in the bulk array. - name: emailSubscription | type: EmailSubscription | description: New or updated email subscription. - 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: error | type: Error | description: Error information if the action failed. Omitted from successful actions. - name: errorCode | type: string | description: Error code. - name: message | type: string | description: Message that contains details about the error. - name: metadata | type: Metadata | description: Numbers of successful and failed actions. - name: totalSuccess | type: integer | description: Number of successful actions. - name: totalFailure | type: integer | description: Number of failed actions. ``` ### Examples ### bulkUpsertEmailSubscription ```javascript import { emailSubscriptions } from '@wix/email-subscriptions'; async function bulkUpsertEmailSubscription(subscriptions) { const response = await emailSubscriptions.bulkUpsertEmailSubscription(subscriptions); }; ``` ### bulkUpsertEmailSubscription (with elevated permissions) ```javascript import { emailSubscriptions } from '@wix/email-subscriptions'; import { auth } from '@wix/essentials'; async function myBulkUpsertEmailSubscriptionMethod(subscriptions) { const elevatedBulkUpsertEmailSubscription = auth.elevate(emailSubscriptions.bulkUpsertEmailSubscription); const response = await elevatedBulkUpsertEmailSubscription(subscriptions); } ``` ### bulkUpsertEmailSubscription (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 { emailSubscriptions } from '@wix/email-subscriptions'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { emailSubscriptions }, // Include the auth strategy and host as relevant }); async function bulkUpsertEmailSubscription(subscriptions) { const response = await myWixClient.emailSubscriptions.bulkUpsertEmailSubscription(subscriptions); }; ``` ---