This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Publishes/sends a specified campaign.
If no emailDistributionOptions
parameters are specified, the campaign is only published as a landing page.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function publishCampaign(
campaignId: string,
options: PublishCampaignOptions,
): Promise<PublishCampaignResponse>;
Campaign ID
Options to use when publishing a campaign.
import { campaigns } from "wix-email-marketing.v2";
// Sample campaignId = "ea46013c-bbbf-4617-ad5d-9247bc4c0970";
export async function myPublishCampaignFunction(campaignId) {
try {
const result = await campaigns.publishCampaign(campaignId);
console.log(
`Success! Your campaign with id: ${campaignId} has been published.`,
);
return result;
} catch (error) {
console.error(error);
}
}
/* Promise resolves to:
* {
* "publishingData": {
* "landingPageUrl": "https://shoutout.wix.com/so/88OduoI8E?languageTag=en",
* "datePublished": "2023-08-17T11:11:06.000Z",
* "wasResentToNonOpeners": false,
* "statistics": {
* "landingPage": {
* "opened": 150,
* "clicked": 80
* },
* "emailCampaign": {
* "opened": 200,
* "clicked": 0,
* "bounced": 0,
* "complained": 0,
* "notSent": 0
* },
* "total": {
* "mailsSent": 1,
* "opened": 200,
* "clicked": 500
* }
* }
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.