Search.../

reuseCampaign( )

Developer Preview

Creates a (draft) copy of an existing campaign.

Description

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 reuseCampaign(campaignId: string): Promise<ReuseCampaignResponse>

reuseCampaign Parameters

NAME
TYPE
DESCRIPTION
campaignId
string

ID of the message to be duplicated.

Returns

Return Type:

Promise<
ReuseCampaignResponse
>
NAME
TYPE
DESCRIPTION
campaign
Campaign

Campaign information.

Was this helpful?

Creates a draft copy of an existing campaign (dashboard page code)

Copy Code
1import { campaigns } from 'wix-email-marketing.v2';
2
3// Sample campaignId = "cc332004-418c-496b-a870-c086790c149d";
4
5export async function myReuseCampaignFunction(campaignId) {
6 try {
7 const result = await campaigns.reuseCampaign(campaignId);
8
9 console.log("Success! Your campaign has been reused.")
10 return result;
11 } catch (error) {
12 console.error(error);
13 }
14}
15
16/* Promise resolves to:
17 * {
18 * "campaign": {
19 * "campaignId": "cc332004-418c-496b-a870-c086790c149d",
20 * "title": "Announcing a Special Offer",
21 * "firstImageUrl": "https://static.wixstatic.com/media/eceb8e_07a78e49568947ffa34fd4983cdd94ae~mv2.png",
22 * "editorType": "WEB",
23 * "status": "ACTIVE",
24 * "visibilityStatus": "DRAFT",
25 * "distributionStatus": "NOT_STARTED",
26 * "dateCreated": "2023-08-13T05:15:32.000Z",
27 * "dateUpdated": "2023-08-13T05:15:32.868Z",
28 * "sendingState": "DRAFT",
29 * "campaignType": "EMAIL_MARKETING"
30 * }
31 * }
32 */
Creates a draft copy of an existing campaign (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { campaigns } from 'wix-email-marketing.v2';
3
4// Sample campaignId = "cc332004-418c-496b-a870-c086790c149d";
5
6export const myReuseCampaignFunction = webMethod(Permissions.Anyone, async (campaignId) => {
7 try {
8 const result = await campaigns.reuseCampaign(campaignId);
9
10 console.log("Success! Your campaign has been reused.")
11 return result;
12 } catch (error) {
13 console.error(error);
14 }
15});
16
17/* Promise resolves to:
18 * {
19 * "campaign": {
20 * "campaignId": "cc332004-418c-496b-a870-c086790c149d",
21 * "title": "Announcing a Special Offer",
22 * "firstImageUrl": "https://static.wixstatic.com/media/eceb8e_07a78e49568947ffa34fd4983cdd94ae~mv2.png",
23 * "editorType": "WEB",
24 * "status": "ACTIVE",
25 * "visibilityStatus": "DRAFT",
26 * "distributionStatus": "NOT_STARTED",
27 * "dateCreated": "2023-08-13T05:15:32.000Z",
28 * "dateUpdated": "2023-08-13T05:15:32.868Z",
29 * "sendingState": "DRAFT",
30 * "campaignType": "EMAIL_MARKETING"
31 * }
32 * }
33 */
Creates a draft copy of an existing campaign with a new title

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { campaigns } from 'wix-email-marketing.v2';
3
4// Sample campaignId = "cc332004-418c-496b-a870-c086790c149d";
5
6export const myReuseCampaignFunction = webMethod(Permissions.Anyone, async (campaignId) => {
7 try {
8 const result = await campaigns.reuseCampaign(campaignId);
9 const updatedTitle = 'Summer Special';
10
11 if (result.campaign.title === 'Announcing a Special Offer') {
12 result.campaign.title = updatedTitle;
13 }
14
15 console.log(`Success! Your campaign with id: ${campaignId} has been reused with an updated title: ${updatedTitle}`)
16 return result;
17 } catch (error) {
18 console.error(error);
19 }
20});
21
22/* Promise resolves to:
23 * {
24 * "campaign": {
25 * "campaignId": "dbdb53d6-c9a8-4475-8aff-f43ca2fdf8c1",
26 * "title": "Summer Special",
27 * "firstImageUrl": "https://static.wixstatic.com/media/eceb8e_07a78e49568947ffa34fd4983cdd94ae~mv2.png",
28 * "editorType": "WEB",
29 * "status": "ACTIVE",
30 * "visibilityStatus": "DRAFT",
31 * "distributionStatus": "NOT_STARTED",
32 * "dateCreated": "2023-08-13T05:15:32.000Z",
33 * "dateUpdated": "2023-08-13T05:15:32.868Z",
34 * "sendingState": "DRAFT",
35 * "campaignType": "EMAIL_MARKETING"
36 * }
37 * }
38 */
39