> 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

# Preview

# Package: emailMarketing

# Namespace: CampaignService

# Method link: https://dev.wix.com/docs/api-reference/business-management/marketing/emails/email-marketing/campaign/preview.md

## Permission Scopes:
Manage Email Marketing: SCOPE.DC-PROMOTE.EMAIL-MARKETING

## Introduction

Builds an HTML preview of the campaign. Use this to display what the email will look like before publishing.

---

## REST API

### Schema

```
 Method: preview
 Description: Builds an HTML preview of the campaign. Use this to display what the email will look like before publishing.
 URL: https://www.wixapis.com/email-marketing/v1/campaigns/{campaignId}/preview
 Method: POST
 Method parameters:
   param name: placeholders | type: placeholders | description: Values to replace campaign placeholders with (unique for each campaign).  | validation: format map
        - name: key | type: string | description: none  
        - name: value | type: PlaceholderContent | description: none  
           - ONE-OF: 
              - name: text | type: PlainText | description: Plain text replacement value.  
                 - name: text | type: string | description: The plain text string.  
              - name: html | type: Html | description: HTML replacement value. Rendered as HTML in supported contexts.  
                 - name: html | type: string | description: The HTML string.  
              - name: money | type: Money | description: Monetary value.  
                 - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative.  | validation: format DECIMAL_VALUE
                 - name: currency | type: string | description: Currency code. Must be valid ISO 4217 currency code (e.g., USD).  | validation: format CURRENCY
                 - name: formattedValue | type: string | description: Monetary amount. Decimal string in local format (e.g., 1 000,30). Optionally, a single (-), to indicate that the amount is negative.  
              - name: dateTime | type: DateTime | description: Date and time value.  
                 - name: timestamp | type: string | description: The point in time.  | validation: format date-time
                 - name: timeZone | type: string | description: IANA time zone name (for example, `"Asia/Jerusalem"`). Used to format the date and time for the recipient's locale.  
              - name: map | type: Map | description: Nested map of placeholder values. Used for structured data.  
                 - name: variables | type: Map<string,PlaceholderContent> | description: Nested placeholder values keyed by name.  | validation: format map
              - name: array | type: Array | description: List of placeholder values.  
                 - name: items | type: array<PlaceholderContent> | description: Ordered list of placeholder values.  
              - name: enum | type: Enum | description: Enum value with a localized display string.  
                 - name: value | type: string | description: Internal enum identifier.  
                 - name: translation | type: string | description: Localized display string for the enum value.  
              - name: attachment | type: Attachment | description: File attachment with a name and download URL.  
                 - name: fileName | type: string | description: Display name of the attached file.  
                 - name: downloadUrl | type: string | description: URL to download the attached file.  
              - name: integer | type: Integer | description: Integer value.  
                 - name: value | type: integer | description: The integer value.  
              - name: decimal | type: Decimal | description: Decimal (fixed-point) value.  
                 - name: value | type: string | description: The decimal value as a string.  | validation: format DECIMAL_VALUE
              - name: localDate | type: LocalDate | description: Local date value without time or timezone.  
                 - name: value | type: string | description: The local date in `YYYY-MM-DD` format.  | validation: format LOCAL_DATE
   param name: removeMissingPlaceholders | type: removeMissingPlaceholders | description: When true, unresolved placeholders are removed from the preview. When false (default), unresolved placeholders remain visible.  
 Return type: PreviewCampaignResponse
  - name: html | type: string | description: Preview HTML.  
  - name: emailSubject | type: string | description: Email subject with resolved dynamic parameters.  | validation: maxLength 1000


```

### Examples

### Preview a Campaign
Builds an HTML preview of the campaign. Use this to display what the email will look like before publishing.

```curl
curl -X POST \
'https://www.wixapis.com/email-marketing/v1/campaigns/943602e1-633b-4577-ab39-43cba3dc17aa/preview' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "placeholders": {
    "firstName": {
      "text": {
        "text": "Jane"
      }
    }
  },
  "removeMissingPlaceholders": true
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.emailMarketing.campaigns.preview(campaignId, options)
 Description: Builds an HTML preview of the campaign. Use this to display what the email will look like before publishing.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  campaignId
 Method parameters: 
   param name: campaignId | type: string | description: GUID of the campaign to preview. | required: true | validation: format GUID
   param name: options | type: PreviewOptions  none  
        - name: placeholders | type: Map<string,PlaceholderContent> | description: Values to replace campaign placeholders with (unique for each campaign).  | validation: format map
           - ONE-OF: 
              - name: text | type: PlainText | description: Plain text replacement value.  
                 - name: text | type: string | description: The plain text string.  
              - name: html | type: Html | description: HTML replacement value. Rendered as HTML in supported contexts.  
                 - name: html | type: string | description: The HTML string.  
              - name: money | type: Money | description: Monetary value.  
                 - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative.  | validation: format DECIMAL_VALUE
                 - name: currency | type: string | description: Currency code. Must be valid ISO 4217 currency code (e.g., USD).  | validation: format CURRENCY
                 - name: formattedValue | type: string | description: Monetary amount. Decimal string in local format (e.g., 1 000,30). Optionally, a single (-), to indicate that the amount is negative.  
              - name: dateTime | type: DateTime | description: Date and time value.  
                 - name: timestamp | type: Date | description: The point in time.  
                 - name: timeZone | type: string | description: IANA time zone name (for example, `"Asia/Jerusalem"`). Used to format the date and time for the recipient's locale.  
              - name: map | type: Map | description: Nested map of placeholder values. Used for structured data.  
                 - name: variables | type: Map<string,PlaceholderContent> | description: Nested placeholder values keyed by name.  | validation: format map
              - name: array | type: Array | description: List of placeholder values.  
                 - name: items | type: array<PlaceholderContent> | description: Ordered list of placeholder values.  
              - name: enum | type: Enum | description: Enum value with a localized display string.  
                 - name: value | type: string | description: Internal enum identifier.  
                 - name: translation | type: string | description: Localized display string for the enum value.  
              - name: attachment | type: Attachment | description: File attachment with a name and download URL.  
                 - name: fileName | type: string | description: Display name of the attached file.  
                 - name: downloadUrl | type: string | description: URL to download the attached file.  
              - name: integer | type: Integer | description: Integer value.  
                 - name: value | type: integer | description: The integer value.  
              - name: decimal | type: Decimal | description: Decimal (fixed-point) value.  
                 - name: value | type: string | description: The decimal value as a string.  | validation: format DECIMAL_VALUE
              - name: localDate | type: LocalDate | description: Local date value without time or timezone.  
                 - name: value | type: string | description: The local date in `YYYY-MM-DD` format.  | validation: format LOCAL_DATE
        - name: removeMissingPlaceholders | type: boolean | description: When true, unresolved placeholders are removed from the preview. When false (default), unresolved placeholders remain visible.  
 Return type: PROMISE<PreviewCampaignResponse>
  - name: html | type: string | description: Preview HTML.  
  - name: emailSubject | type: string | description: Email subject with resolved dynamic parameters.  | validation: maxLength 1000


```

### Examples

### preview
```javascript
import { campaigns } from '@wix/email-marketing';

async function preview(campaignId,options) {
  const response = await campaigns.preview(campaignId,options);
};
```

### preview (with elevated permissions)
```javascript
import { campaigns } from '@wix/email-marketing';
import { auth } from '@wix/essentials';

async function myPreviewMethod(campaignId,options) {
  const elevatedPreview = auth.elevate(campaigns.preview);
  const response = await elevatedPreview(campaignId,options);
}
```

### preview (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 { campaigns } from '@wix/email-marketing';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { campaigns },
  // Include the auth strategy and host as relevant
});


async function preview(campaignId,options) {
  const response = await myWixClient.campaigns.preview(campaignId,options);
};
```

---