> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# List

# Package: emailMarketing

# Namespace: CampaignService

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

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

## Introduction

Retrieves a list of email campaigns.

Sorted by `dateUpdated` in `DESC` order by default.

`paging.limit` defaults to `100`, which is also the maximum. `paging.offset` is rounded down to the nearest multiple of `paging.limit`.

---

## REST API

### Schema

```
 Method: list
 Description: Retrieves a list of email campaigns.  Sorted by `dateUpdated` in `DESC` order by default.  `paging.limit` defaults to `100`, which is also the maximum. `paging.offset` is rounded down to the nearest multiple of `paging.limit`.
 URL: https://www.wixapis.com/email-marketing/v1/campaigns
 Method: GET
 Method parameters:
   query param name: campaignIds | type: array<campaignIds> | description: IDs of campaigns to retrieve. GUIDs of campaigns that don't exist or were deleted are ignored. Other filters, such as `statuses`, still apply.  | validation: maxItems 100, format GUID
   query param name: optionIncludeStatistics | type: optionIncludeStatistics | description: Whether to include `publishingData.statistics` in the returned campaign object.  Default: `false`.  
   param name: paging | type: Paging    
        - name: limit | type: integer | description: Number of items to load.  | validation: minimum 0, format int32
        - name: offset | type: integer | description: Number of items to skip in the current sort order.  | validation: minimum 0, format int32
   query param name: statuses | type: array<statuses> | description: Campaign statuses to filter by. When not specified, returns campaigns with `ACTIVE` and `ARCHIVED` statuses.  
                 - enum:
                 -     ACTIVE: Campaign is active.
                 -     ARCHIVED: Campaign is archived.
                 -     DELETED: Campaign is deleted.
   query param name: visibilityStatuses | type: array<visibilityStatuses> | description: Visibility statuses to filter by.  
                 - enum:
                 -     DRAFT: Campaign isn't published yet.
                 -     PUBLISHED: Campaign is published.
                 -     TEMPLATE: Campaign is a template.
 Return type: ListCampaignsResponse
  - name: paging | type: Paging | description: Paging parameters.  
     - name: limit | type: integer | description: Number of items to load.  | validation: minimum 0, format int32
     - name: offset | type: integer | description: Number of items to skip in the current sort order.  | validation: minimum 0, format int32
  - name: campaigns | type: array<Campaign> | description: List of campaigns.  
     - name: campaignId | type: string | description: Campaign GUID.  | validation: format GUID
     - name: title | type: string | description: Campaign title. Used to identify the campaign in the dashboard. Defaults to the email subject if not provided.  
     - name: firstImageUrl | type: string | description: URL of the first image after the logo.  | validation: format WEB_URL
     - name: editorType | type: Enum | description: Editor type that determines the format of `composerDataJson`.  
         - enum:
         -     WEB: Wix classic drag-and-drop email editor. The `composerDataJson` is stored in Wix proprietary JSON format.
         -     MOBILE: Wix classic mobile-optimized email editor. The `composerDataJson` is stored in a subset of the `WEB` format.
         -     MJML: AI-powered email editor. The `composerDataJson` is stored in MJML markup wrapped in JSON.
         -     HTML: HTML email editor. The `composerDataJson` is stored in raw HTML code wrapped in JSON.
     - name: status | type: Enum | description: Campaign status.  
         - enum:
         -     ACTIVE: Campaign is active.
         -     ARCHIVED: Campaign is archived.
         -     DELETED: Campaign is deleted.
     - name: visibilityStatus | type: Enum | description: Whether the campaign is a draft, published, or a template.  
         - enum:
         -     DRAFT: Campaign isn't published yet.
         -     PUBLISHED: Campaign is published.
         -     TEMPLATE: Campaign is a template.
     - name: distributionStatus | type: Enum | description: Campaign distribution status.  
         - enum:
         -     NOT_STARTED: Campaign isn't distributed to recipients yet.
         -     SCHEDULED: Campaign is scheduled for distribution.
         -     IN_DETECTION: Campaign is in screening for malicious content.
         -     IN_MODERATION: Campaign is in review by the site moderators.
         -     SAMPLING: A subset of recipients receives the campaign first to check for deliverability issues before sending to the full audience.
         -     SENDING: Campaign is being sent out to all recipients.
         -     REJECTED: Campaign was identified as abusive and rejected before sending.
         -     TERMINATED: Campaign is terminated after a failed sampling test. It can be sent to the remaining recipients after user takes action to clean remaining recipient list from unsolicited recipients.
         -     DISTRIBUTED: Campaign is fully distributed to all recipients.
         -     PAUSED: Scheduled campaign is paused.
     - name: publishingData | type: PublishingData | description: Publishing data. The field is returned empty if the campaign isn't published.  
        - name: landingPageUrl | type: string | description: Landing page URL.  | validation: format WEB_URL
        - name: statistics | type: CampaignStatistics | description: Campaign engagement statistics.  
           - name: landingPage | type: LandingPageStatistics | description: Landing page statistics.  
              - name: opened | type: integer | description: Number of times the landing page was loaded or viewed.  
              - name: clicked | type: integer | description: Number of times a link was clicked in a landing page.  
           - name: emailCampaign | type: DistributionStatistics | description: Email distribution statistics.  
              - name: delivered | type: integer | description: Number of delivered emails.  
              - name: opened | type: integer | description: Number of recipients who opened an email.  If the same recipient opened the same email twice, it is counted as a one unique open.  
              - name: clicked | type: integer | description: Number of recipients who clicked a link in the email.  If the same recipient clicked the same link twice, it is counted as a one unique click.  If the same recipient clicked different links, it is counted as a one unique click.  
              - name: bounced | type: integer | description: Number of emails that didn't reach the recipient.  
              - name: complained | type: integer | description: Number of recipients who reported the email as spam.  
              - name: notSent | type: integer | description: Number of audience members who didn't receive the email because the campaign was terminated during sampling before reaching the full audience.  
           - name: total | type: TotalStatistics | description: Combined statistics of landing page and email distribution.  
              - name: mailsSent | type: integer | description: Total number of emails sent.  
              - name: opened | type: integer | description: Number of landing page views and opened emails.  
              - name: clicked | type: integer | description: Number of landing page and email link clicks.  
        - name: datePublished | type: string | description: Date and time the campaign was published.  | validation: format date-time
        - name: wasResentToNonOpeners | type: boolean | description: Whether the campaign was resent to recipients who didn't open the original email.  
     - name: dateCreated | type: string | description: Date and time the campaign was created.  | validation: format date-time
     - name: dateUpdated | type: string | description: Date and time the campaign was updated.  | validation: format date-time
     - name: dateScheduled | type: string | description: Date and time the campaign is scheduled to be sent. Returned only for campaigns published with `emailDistributionOptions.sendAt` or resent with `sendAt`, and kept after the campaign is sent or its scheduling is paused.  | validation: format date-time
     - name: rejectionData | type: RejectionData | description: Reasons the campaign was rejected. Returned only for campaigns with a `REJECTED` distribution status.  
        - name: rejectionReasons | type: array<Enum> | description: Reasons the campaign was rejected.  
             - enum:
             -     LOW_ENGAGEMENT: Historical engagement rates are too low for healthy deliverability.
             -     SENDER_DETAILS: Sender details are invalid or blacklisted.
             -     SPAM_TRAPS: Mailing list contains spam trap addresses.
             -     OTHER: Other compliance reason.
             -     ADULT_SEXUAL_CONTENT: Campaign contains adult or sexual content.
             -     AFFILIATE_MARKETING: Campaign promotes affiliate marketing.
             -     BETTING_OR_GAMBLING: Campaign promotes betting or gambling.
             -     CREDIT_REPAIR_OR_DEBT_RELIEF: Campaign promotes credit repair or debt relief services.
             -     GET_RICH_QUICK_SCHEME: Campaign promotes a get-rich-quick scheme.
             -     ILLEGAL_SUBSTANCES_OR_WEAPONS: Campaign promotes illegal substances or weapons.
             -     MISLEADING_SUBJECT_LINE: Campaign subject line is misleading.
             -     TRADING_OR_CRYPTOCURRENCIES: Campaign promotes trading or cryptocurrencies.
             -     UNSOLICITED_CONTENT: Campaign content wasn't explicitly requested by recipients.
             -     MAX_AUDIENCE_SIZE_EXCEEDED: Audience size exceeds the maximum allowed for the current plan.
     - name: samplingData | type: SamplingData | description: SamplingData is only present if the campaign's audience was sampled before sending. Populated once the campaign enters SAMPLING. If the sample fails, distributionStatus is TERMINATED.  
        - name: totalContactCount | type: integer | description: Number of contacts in the campaign's audience.  
        - name: newContactCount | type: integer | description: Number of audience contacts that were not previously emailed.  
        - name: sampleContactCount | type: integer | description: Number of contacts the campaign was sent to as the sample.  
        - name: evaluation | type: SamplingEvaluation | description: Sampling results. Only present after the sample was evaluated.  
           - name: hardBounces | type: SamplingThresholdCheck | description: Hard bounces check.  
              - name: count | type: integer | description: Number of occurrences found in the sample.  
              - name: exceeded | type: boolean | description: Whether the count exceeded the allowed threshold.  
           - name: spamComplaints | type: SamplingThresholdCheck | description: Spam complaints check.  
           - name: spamTraps | type: SamplingThresholdCheck | description: Spam traps check.  
        - name: userActions | type: SamplingUserActions | description: Actions the user took after sampling failed. Read-only: set when the user acts in the Wix dashboard.  
           - name: labelKey | type: string | description: Key of the label that was added to the contacts the campaign wasn't sent to.  | validation: minLength 1, maxLength 80
           - name: dateResent | type: string | description: Date and time the campaign was resent to the contacts it wasn't sent to.  | validation: format date-time

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_CAMPAIGN_TYPE | Description: none


```

### Examples

### List Campaigns
Retrieve a list of email campaigns for the site.

```curl
curl -X GET \
'https://www.wixapis.com/email-marketing/v1/campaigns' \
-H 'Authorization: <AUTH>'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.emailMarketing.campaigns.listCampaigns(options)
 Description: Retrieves a list of email campaigns.  Sorted by `dateUpdated` in `DESC` order by default.  `paging.limit` defaults to `100`, which is also the maximum. `paging.offset` is rounded down to the nearest multiple of `paging.limit`.
 Method parameters:
   param name: options | type: ListOptions  none  
        - name: paging | type: Paging | description: Paging parameters.  
           - name: limit | type: integer | description: Number of items to load.  | validation: minimum 0, format int32
           - name: offset | type: integer | description: Number of items to skip in the current sort order.  | validation: minimum 0, format int32
        - name: optionIncludeStatistics | type: boolean | description: Whether to include `publishingData.statistics` in the returned campaign object.  Default: `false`.  
        - name: statuses | type: array<Enum> | description: Campaign statuses to filter by. When not specified, returns campaigns with `ACTIVE` and `ARCHIVED` statuses.  
             - enum:
             -     ACTIVE: Campaign is active.
             -     ARCHIVED: Campaign is archived.
             -     DELETED: Campaign is deleted.
        - name: visibilityStatuses | type: array<Enum> | description: Visibility statuses to filter by.  
             - enum:
             -     DRAFT: Campaign isn't published yet.
             -     PUBLISHED: Campaign is published.
             -     TEMPLATE: Campaign is a template.
        - name: campaignIds | type: array<string> | description: IDs of campaigns to retrieve. GUIDs of campaigns that don't exist or were deleted are ignored. Other filters, such as `statuses`, still apply.  | validation: maxItems 100, format GUID
 Return type: PROMISE<ListCampaignsResponse>
  - name: paging | type: Paging | description: Paging parameters.  
     - name: limit | type: integer | description: Number of items to load.  | validation: minimum 0, format int32
     - name: offset | type: integer | description: Number of items to skip in the current sort order.  | validation: minimum 0, format int32
  - name: campaigns | type: array<Campaign> | description: List of campaigns.  
     - name: campaignId | type: string | description: Campaign GUID.  | validation: format GUID
     - name: title | type: string | description: Campaign title. Used to identify the campaign in the dashboard. Defaults to the email subject if not provided.  
     - name: firstImageUrl | type: string | description: URL of the first image after the logo.  | validation: format WEB_URL
     - name: editorType | type: Enum | description: Editor type that determines the format of `composerDataJson`.  
         - enum:
         -     WEB: Wix classic drag-and-drop email editor. The `composerDataJson` is stored in Wix proprietary JSON format.
         -     MOBILE: Wix classic mobile-optimized email editor. The `composerDataJson` is stored in a subset of the `WEB` format.
         -     MJML: AI-powered email editor. The `composerDataJson` is stored in MJML markup wrapped in JSON.
         -     HTML: HTML email editor. The `composerDataJson` is stored in raw HTML code wrapped in JSON.
     - name: status | type: Enum | description: Campaign status.  
         - enum:
         -     ACTIVE: Campaign is active.
         -     ARCHIVED: Campaign is archived.
         -     DELETED: Campaign is deleted.
     - name: visibilityStatus | type: Enum | description: Whether the campaign is a draft, published, or a template.  
         - enum:
         -     DRAFT: Campaign isn't published yet.
         -     PUBLISHED: Campaign is published.
         -     TEMPLATE: Campaign is a template.
     - name: distributionStatus | type: Enum | description: Campaign distribution status.  
         - enum:
         -     NOT_STARTED: Campaign isn't distributed to recipients yet.
         -     SCHEDULED: Campaign is scheduled for distribution.
         -     IN_DETECTION: Campaign is in screening for malicious content.
         -     IN_MODERATION: Campaign is in review by the site moderators.
         -     SAMPLING: A subset of recipients receives the campaign first to check for deliverability issues before sending to the full audience.
         -     SENDING: Campaign is being sent out to all recipients.
         -     REJECTED: Campaign was identified as abusive and rejected before sending.
         -     TERMINATED: Campaign is terminated after a failed sampling test. It can be sent to the remaining recipients after user takes action to clean remaining recipient list from unsolicited recipients.
         -     DISTRIBUTED: Campaign is fully distributed to all recipients.
         -     PAUSED: Scheduled campaign is paused.
     - name: publishingData | type: PublishingData | description: Publishing data. The field is returned empty if the campaign isn't published.  
        - name: landingPageUrl | type: string | description: Landing page URL.  | validation: format WEB_URL
        - name: statistics | type: CampaignStatistics | description: Campaign engagement statistics.  
           - name: landingPage | type: LandingPageStatistics | description: Landing page statistics.  
              - name: opened | type: integer | description: Number of times the landing page was loaded or viewed.  
              - name: clicked | type: integer | description: Number of times a link was clicked in a landing page.  
           - name: emailCampaign | type: DistributionStatistics | description: Email distribution statistics.  
              - name: delivered | type: integer | description: Number of delivered emails.  
              - name: opened | type: integer | description: Number of recipients who opened an email.  If the same recipient opened the same email twice, it is counted as a one unique open.  
              - name: clicked | type: integer | description: Number of recipients who clicked a link in the email.  If the same recipient clicked the same link twice, it is counted as a one unique click.  If the same recipient clicked different links, it is counted as a one unique click.  
              - name: bounced | type: integer | description: Number of emails that didn't reach the recipient.  
              - name: complained | type: integer | description: Number of recipients who reported the email as spam.  
              - name: notSent | type: integer | description: Number of audience members who didn't receive the email because the campaign was terminated during sampling before reaching the full audience.  
           - name: total | type: TotalStatistics | description: Combined statistics of landing page and email distribution.  
              - name: mailsSent | type: integer | description: Total number of emails sent.  
              - name: opened | type: integer | description: Number of landing page views and opened emails.  
              - name: clicked | type: integer | description: Number of landing page and email link clicks.  
        - name: datePublished | type: Date | description: Date and time the campaign was published.  
        - name: wasResentToNonOpeners | type: boolean | description: Whether the campaign was resent to recipients who didn't open the original email.  
     - name: dateCreated | type: Date | description: Date and time the campaign was created.  
     - name: dateUpdated | type: Date | description: Date and time the campaign was updated.  
     - name: dateScheduled | type: Date | description: Date and time the campaign is scheduled to be sent. Returned only for campaigns published with `emailDistributionOptions.sendAt` or resent with `sendAt`, and kept after the campaign is sent or its scheduling is paused.  
     - name: rejectionData | type: RejectionData | description: Reasons the campaign was rejected. Returned only for campaigns with a `REJECTED` distribution status.  
        - name: rejectionReasons | type: array<Enum> | description: Reasons the campaign was rejected.  
             - enum:
             -     LOW_ENGAGEMENT: Historical engagement rates are too low for healthy deliverability.
             -     SENDER_DETAILS: Sender details are invalid or blacklisted.
             -     SPAM_TRAPS: Mailing list contains spam trap addresses.
             -     OTHER: Other compliance reason.
             -     ADULT_SEXUAL_CONTENT: Campaign contains adult or sexual content.
             -     AFFILIATE_MARKETING: Campaign promotes affiliate marketing.
             -     BETTING_OR_GAMBLING: Campaign promotes betting or gambling.
             -     CREDIT_REPAIR_OR_DEBT_RELIEF: Campaign promotes credit repair or debt relief services.
             -     GET_RICH_QUICK_SCHEME: Campaign promotes a get-rich-quick scheme.
             -     ILLEGAL_SUBSTANCES_OR_WEAPONS: Campaign promotes illegal substances or weapons.
             -     MISLEADING_SUBJECT_LINE: Campaign subject line is misleading.
             -     TRADING_OR_CRYPTOCURRENCIES: Campaign promotes trading or cryptocurrencies.
             -     UNSOLICITED_CONTENT: Campaign content wasn't explicitly requested by recipients.
             -     MAX_AUDIENCE_SIZE_EXCEEDED: Audience size exceeds the maximum allowed for the current plan.
     - name: samplingData | type: SamplingData | description: SamplingData is only present if the campaign's audience was sampled before sending. Populated once the campaign enters SAMPLING. If the sample fails, distributionStatus is TERMINATED.  
        - name: totalContactCount | type: integer | description: Number of contacts in the campaign's audience.  
        - name: newContactCount | type: integer | description: Number of audience contacts that were not previously emailed.  
        - name: sampleContactCount | type: integer | description: Number of contacts the campaign was sent to as the sample.  
        - name: evaluation | type: SamplingEvaluation | description: Sampling results. Only present after the sample was evaluated.  
           - name: hardBounces | type: SamplingThresholdCheck | description: Hard bounces check.  
              - name: count | type: integer | description: Number of occurrences found in the sample.  
              - name: exceeded | type: boolean | description: Whether the count exceeded the allowed threshold.  
           - name: spamComplaints | type: SamplingThresholdCheck | description: Spam complaints check.  
           - name: spamTraps | type: SamplingThresholdCheck | description: Spam traps check.  
        - name: userActions | type: SamplingUserActions | description: Actions the user took after sampling failed. Read-only: set when the user acts in the Wix dashboard.  
           - name: labelKey | type: string | description: Key of the label that was added to the contacts the campaign wasn't sent to.  | validation: minLength 1, maxLength 80
           - name: dateResent | type: Date | description: Date and time the campaign was resent to the contacts it wasn't sent to.  

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_CAMPAIGN_TYPE | Description: none


```

### Examples

### Returns a list of email campaigns based on optional data
```javascript
import { campaigns } from '@wix/email-marketing';

// Sample options value:
// {
//    options: {
//      campaignType: 'AUTOMATION', 
//      statuses: ['DELETED'],
//      visibilityStatuses: ['PUBLISHED]
//   }
// }

export async function myListCampaignsFunction(options) {
  try {
    const results = await campaigns.listCampaigns(options);

    console.log('Success! Retrieved results:', results);
    return results;
  } catch (error) {
    console.error(error);
  }
}

/* Promise resolves to:
 * {
 *   "campaigns": [
 *     {
 *       "campaignId": "b98a4436-10f5-47bd-9c6f-370962adfe54",
 *       "title": "A New Tutorial for You",
 *       "firstImageUrl": "https://static.wixstatic.com/media/6191b8_77d27f7d028a4b50850b7f92dadcd578~mv2.png",
 *       "editorType": "WEB",
 *       "status": "DELETED",
 *       "visibilityStatus": "PUBLISHED",
 *       "distributionStatus": "DISTRIBUTED",
 *       "publishingData": {
 *         "landingPageUrl": "https://shoutout.wix.com/so/54OdUqUrf?languageTag=en",
 *         "datePublished": "2023-08-10T09:40:59.000Z",
 *         "wasResentToNonOpeners": false
 *       },
 *       "dateCreated": "2023-08-10T09:40:47.000Z",
 *       "dateUpdated": "2023-08-10T09:40:59.045Z",
 *       "sendingState": "SENT",
 *       "campaignType": "EMAIL_MARKETING"
 *     },
 *     {
 *       "campaignId": "fb21c999-40b5-4364-8e75-18273da41983",
 *       "title": "What did we do last month?",
 *       "firstImageUrl": "https://static.wixstatic.com/media/eceb8e_e65cd7284b4c4144a4fb8b2f3ce30a68~mv2_d_2000_1334_s_2.png",
 *       "editorType": "WEB",
 *       "status": "DELETED",
 *       "visibilityStatus": "PUBLISHED",
 *       "distributionStatus": "DISTRIBUTED",
 *       "publishingData": {
 *         "landingPageUrl": "https://shoutout.wix.com/so/83OdQ8pDA?languageTag=en",
 *         "datePublished": "2023-08-10T09:25:15.000Z",
 *         "wasResentToNonOpeners": false
 *       },
 *       "dateCreated": "2023-08-09T11:51:27.000Z",
 *       "dateUpdated": "2023-08-10T09:25:14.952Z",
 *       "sendingState": "SENT",
 *       "campaignType": "EMAIL_MARKETING"
 *     }
 *   ]
 * }
 */
```

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

const elevatedListCampaigns = auth.elevate(campaigns.listCampaigns);

// Sample options value:
// {
//    paging: {
//      limit: 2, 
//      offset: 0 
//   }
// }
 
export async function myListCampaignsFunction(options) {
  try {
    const results = await elevatedListCampaigns(options);

    console.log('Success! Retrieved results:', results);
    return results;
  } catch (error) {
    console.error(error);
  }
}

/* Promise resolves to:
 * {
 *   "campaigns": [
 *     {
 *       "campaignId": "b98a4436-10f5-47bd-9c6f-370962adfe54",
 *       "title": "A New Tutorial for You",
 *       "firstImageUrl": "https://static.wixstatic.com/media/6191b8_77d27f7d028a4b50850b7f92dadcd578~mv2.png",
 *       "editorType": "WEB",
 *       "status": "ACTIVE",
 *       "visibilityStatus": "PUBLISHED",
 *       "distributionStatus": "DISTRIBUTED",
 *       "publishingData": {
 *         "landingPageUrl": "https://shoutout.wix.com/so/54OdUqUrf?languageTag=en",
 *         "datePublished": "2023-08-10T09:40:59.000Z",
 *         "wasResentToNonOpeners": false
 *       },
 *       "dateCreated": "2023-08-10T09:40:47.000Z",
 *       "dateUpdated": "2023-08-10T09:40:59.045Z",
 *       "sendingState": "SENT",
 *       "campaignType": "EMAIL_MARKETING"
 *     },
 *     {
 *       "campaignId": "fb21c999-40b5-4364-8e75-18273da41983",
 *       "title": "What did we do last month?",
 *       "firstImageUrl": "https://static.wixstatic.com/media/eceb8e_e65cd7284b4c4144a4fb8b2f3ce30a68~mv2_d_2000_1334_s_2.png",
 *       "editorType": "WEB",
 *       "status": "ACTIVE",
 *       "visibilityStatus": "PUBLISHED",
 *       "distributionStatus": "DISTRIBUTED",
 *       "publishingData": {
 *         "landingPageUrl": "https://shoutout.wix.com/so/83OdQ8pDA?languageTag=en",
 *         "datePublished": "2023-08-10T09:25:15.000Z",
 *         "wasResentToNonOpeners": false
 *       },
 *       "dateCreated": "2023-08-09T11:51:27.000Z",
 *       "dateUpdated": "2023-08-10T09:25:14.952Z",
 *       "sendingState": "SENT",
 *       "campaignType": "EMAIL_MARKETING"
 *     }
 *    ]
 * }
 */
```

### Returns a list of email campaigns
```javascript
import { campaigns } from '@wix/email-marketing';

// Sample options value:
// {
//    paging: {
//      limit: 2, 
//      offset: 0 
//   }
// }
 
export async function myListCampaignsFunction(options) {
  try {
    const results = await campaigns.listCampaigns(options);

    console.log('Success! Retrieved results:', results);
    return results;
  } catch (error) {
    console.error(error);
  }
}

/* Promise resolves to:
 * {
 *   "campaigns": [
 *     {
 *       "campaignId": "b98a4436-10f5-47bd-9c6f-370962adfe54",
 *       "title": "A New Tutorial for You",
 *       "firstImageUrl": "https://static.wixstatic.com/media/6191b8_77d27f7d028a4b50850b7f92dadcd578~mv2.png",
 *       "editorType": "WEB",
 *       "status": "ACTIVE",
 *       "visibilityStatus": "PUBLISHED",
 *       "distributionStatus": "DISTRIBUTED",
 *       "publishingData": {
 *         "landingPageUrl": "https://shoutout.wix.com/so/54OdUqUrf?languageTag=en",
 *         "datePublished": "2023-08-10T09:40:59.000Z",
 *         "wasResentToNonOpeners": false
 *       },
 *       "dateCreated": "2023-08-10T09:40:47.000Z",
 *       "dateUpdated": "2023-08-10T09:40:59.045Z",
 *       "sendingState": "SENT",
 *       "campaignType": "EMAIL_MARKETING"
 *     },
 *     {
 *       "campaignId": "fb21c999-40b5-4364-8e75-18273da41983",
 *       "title": "What did we do last month?",
 *       "firstImageUrl": "https://static.wixstatic.com/media/eceb8e_e65cd7284b4c4144a4fb8b2f3ce30a68~mv2_d_2000_1334_s_2.png",
 *       "editorType": "WEB",
 *       "status": "ACTIVE",
 *       "visibilityStatus": "PUBLISHED",
 *       "distributionStatus": "DISTRIBUTED",
 *       "publishingData": {
 *         "landingPageUrl": "https://shoutout.wix.com/so/83OdQ8pDA?languageTag=en",
 *         "datePublished": "2023-08-10T09:25:15.000Z",
 *         "wasResentToNonOpeners": false
 *       },
 *       "dateCreated": "2023-08-09T11:51:27.000Z",
 *       "dateUpdated": "2023-08-10T09:25:14.952Z",
 *       "sendingState": "SENT",
 *       "campaignType": "EMAIL_MARKETING"
 *     }
 *    ]
 * }
 */
```

### Returns a list of email campaigns and adds the campaign title to your database (with elevated permissions)
```javascript
import { campaigns } from '@wix/email-marketing';
import { items } from '@wix/data';
import { auth } from '@wix/essentials';

const elevatedListCampaigns = auth.elevate(campaigns.listCampaigns);

export async function myListCampaignsFunction() {
  try {
    const result = await elevatedListCampaigns();

    const campaignTitle = result.campaigns[0].title;
    console.log(campaignTitle);  
    // store campaign title in your database
    let toInsert = {
        "campaignTitle": campaignTitle
    };
    
    const results = await items.insert('myDatabaseCollection', toInsert);
    console.log(`Data inserted successfully. The item ID is: ${results.itemId}`); // Data inserted successfully. The item ID is: 532549d4-2a95-45cc-bb8e-4cb39422e42c
    return { "campaignTitle": campaignTitle }

  } catch (error) {
      console.error(error);
      return { "error": "Failed to find and insert data." };
  }
}

/*
 * Promise returns:
 * {
 *   "campaignTitle": "A New Tutorial for You"
 * }
 */
```

### Returns a list of email campaigns and adds the campaign title to your database
```javascript
import { campaigns } from '@wix/email-marketing';
import { items } from '@wix/data';

export async function myListCampaignsFunction() {
  try {
    const result = await campaigns.listCampaigns();

    const campaignTitle = result.campaigns[0].title;
    console.log(campaignTitle);  
    // store campaign title in your database
    let toInsert = {
        "campaignTitle": campaignTitle
    };
    
    const results = await items.insert('myDatabaseCollection', toInsert);
    console.log(`Data inserted successfully. The item ID is: ${results.itemId}`); // Data inserted successfully. The item ID is: 532549d4-2a95-45cc-bb8e-4cb39422e42c
    return { "campaignTitle": campaignTitle }

  } catch (error) {
      console.error(error);
      return { "error": "Failed to find and insert data." };
  }
}

/*
 * Promise returns:
 * {
 *   "campaignTitle": "A New Tutorial for You"
 * }
 */
```

### Returns a list of email campaigns based on optional data (with elevated permissions)
```javascript
import { campaigns } from '@wix/email-marketing';
import { auth } from '@wix/essentials';

const elevatedListCampaigns = auth.elevate(campaigns.listCampaigns);

// Sample options value:
// {
//    options: {
//      campaignType: 'AUTOMATION', 
//      statuses: ['DELETED'],
//      visibilityStatuses: ['PUBLISHED]
//   }
// }

export async function myListCampaignsFunction(options) {
  try {
    const results = await elevatedListCampaigns(options);

    console.log('Success! Retrieved results:', results);
    return results;
  } catch (error) {
    console.error(error);
  }
}

/* Promise resolves to:
 * {
 *   "campaigns": [
 *     {
 *       "campaignId": "b98a4436-10f5-47bd-9c6f-370962adfe54",
 *       "title": "A New Tutorial for You",
 *       "firstImageUrl": "https://static.wixstatic.com/media/6191b8_77d27f7d028a4b50850b7f92dadcd578~mv2.png",
 *       "editorType": "WEB",
 *       "status": "DELETED",
 *       "visibilityStatus": "PUBLISHED",
 *       "distributionStatus": "DISTRIBUTED",
 *       "publishingData": {
 *         "landingPageUrl": "https://shoutout.wix.com/so/54OdUqUrf?languageTag=en",
 *         "datePublished": "2023-08-10T09:40:59.000Z",
 *         "wasResentToNonOpeners": false
 *       },
 *       "dateCreated": "2023-08-10T09:40:47.000Z",
 *       "dateUpdated": "2023-08-10T09:40:59.045Z",
 *       "sendingState": "SENT",
 *       "campaignType": "EMAIL_MARKETING"
 *     },
 *     {
 *       "campaignId": "fb21c999-40b5-4364-8e75-18273da41983",
 *       "title": "What did we do last month?",
 *       "firstImageUrl": "https://static.wixstatic.com/media/eceb8e_e65cd7284b4c4144a4fb8b2f3ce30a68~mv2_d_2000_1334_s_2.png",
 *       "editorType": "WEB",
 *       "status": "DELETED",
 *       "visibilityStatus": "PUBLISHED",
 *       "distributionStatus": "DISTRIBUTED",
 *       "publishingData": {
 *         "landingPageUrl": "https://shoutout.wix.com/so/83OdQ8pDA?languageTag=en",
 *         "datePublished": "2023-08-10T09:25:15.000Z",
 *         "wasResentToNonOpeners": false
 *       },
 *       "dateCreated": "2023-08-09T11:51:27.000Z",
 *       "dateUpdated": "2023-08-10T09:25:14.952Z",
 *       "sendingState": "SENT",
 *       "campaignType": "EMAIL_MARKETING"
 *     }
 *   ]
 * }
 */
```

### listCampaigns (self-managed)
Self-managed 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 listCampaigns(options) {
  const response = await myWixClient.campaigns.listCampaigns(options);
};
```

---