Search.../

publishCampaign( )

Developer Preview

Publishes/sends a specified campaign.

Description

If no emailDistributionOptions parameters are specified, the campaign is only published as a landing page.

This function is not a universal function and runs only on the backend.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function publishCampaign(campaignId: string, options: PublishCampaignOptions): Promise<PublishCampaignResponse>

publishCampaign Parameters

NAME
TYPE
DESCRIPTION
campaignId
string

Campaign ID

options
Optional
PublishCampaignOptions

Options to use when publishing a campaign.

Returns

Return Type:

Promise<
PublishCampaignResponse
>
NAME
TYPE
DESCRIPTION
publishingData
PublishingData

publishingData.statistics will be empty.

Was this helpful?

Publishes specified campaign

Copy Code
1import { campaigns } from 'wix-email-marketing.v2';
2
3// Sample campaignId = "ea46013c-bbbf-4617-ad5d-9247bc4c0970";
4
5export async function myPublishCampaignFunction(campaignId) {
6 try {
7 const result = await campaigns.publishCampaign(campaignId);
8
9 console.log(`Success! Your campaign with id: ${campaignId} has been published.`)
10 return result;
11 } catch (error) {
12 console.error(error);
13 }
14}
15
16/* Promise resolves to:
17 * {
18 * "publishingData": {
19 * "landingPageUrl": "https://shoutout.wix.com/so/88OduoI8E?languageTag=en",
20 * "datePublished": "2023-08-17T11:11:06.000Z",
21 * "wasResentToNonOpeners": false,
22 * "statistics": {
23 * "landingPage": {
24 * "opened": 150,
25 * "clicked": 80
26 * },
27 * "emailCampaign": {
28 * "opened": 200,
29 * "clicked": 0,
30 * "bounced": 0,
31 * "complained": 0,
32 * "notSent": 0
33 * },
34 * "total": {
35 * "mailsSent": 1,
36 * "opened": 200,
37 * "clicked": 500
38 * }
39 * }
40 * }
41 * }
42 */