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

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 with a new title

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 const updatedTitle = 'Summer Special';
9
10 if (result.campaign.title === 'Announcing a Special Offer') {
11 result.campaign.title = updatedTitle;
12 }
13
14 console.log(`Success! Your campaign with id: ${campaignId} has been reused with a updated title: ${newTitle}`)
15 return result;
16 } catch (error) {
17 console.error(error);
18 }
19}
20
21/* Promise resolves to:
22 * {
23 * "campaign": {
24 * "campaignId": "dbdb53d6-c9a8-4475-8aff-f43ca2fdf8c1",
25 * "title": "Summer Special",
26 * "firstImageUrl": "https://static.wixstatic.com/media/eceb8e_07a78e49568947ffa34fd4983cdd94ae~mv2.png",
27 * "editorType": "WEB",
28 * "status": "ACTIVE",
29 * "visibilityStatus": "DRAFT",
30 * "distributionStatus": "NOT_STARTED",
31 * "dateCreated": "2023-08-13T05:15:32.000Z",
32 * "dateUpdated": "2023-08-13T05:15:32.868Z",
33 * "sendingState": "DRAFT",
34 * "campaignType": "EMAIL_MARKETING"
35 * }
36 * }
37 */