> 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

# Package: emailMarketing

# Namespace: campaign

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

# Webhook Permissions Scopes IDs:
Read Email Marketing: SCOPE.DC-PROMOTE.READ-EMAIL-MARKETING

## Introduction

Triggered when a campaign is created.

---

## REST API

### Schema

```
Webhook: Campaign Created
Description: Triggered when a campaign is created.
Event body:
 - name: id | type: string | description: Unique event ID. Allows clients to ignore duplicate events.
 - name: entityFqdn | type: string | description: Fully qualified domain name of the entity associated with the event.
 - name: slug | type: string | description: Event name.
 - name: entityId | type: string | description: ID of the entity associated with the event.
 - name: eventTime | type: string (date-time) | description: Event timestamp.
 - name: triggeredByAnonymizeRequest | type: boolean | description: Whether the event was triggered as a result of a privacy regulation application such as GDPR.
 - name: originatedFrom | type: string | description: If present, indicates the action that triggered the event.
 - name: createdEvent | type: object | description: Created event details.
    - name: entity | type: Campaign | description: The created entity.
        - name: campaignId | type: string | description: Campaign 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.
        - 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.
           - 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.
           - 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.
        - name: dateUpdated | type: string | description: Date and time the campaign was updated.
        - 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.
        - 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.
              - name: dateResent | type: string | description: Date and time the campaign was resent to the contacts it wasn't sent to.

```

### Examples


```curl
{
  "entityId": "38d837a5-8303-413c-8ac0-75d735a4bdb0",
  "actionEvent": {
    "body": {
      "campaignId": "c9b491f8-bad0-4d0d-8a1c-c90055d31553",
      "title": "Email subject",
      "firstImageUrl": "//static.wixstatic.com/media/eceb8e_e1f32b0d497447a8898e7abcf01d7d87~mv2_d_5600_3733_s_4_2.jpg",
      "editorType": "WEB",
      "status": "ACTIVE",
      "visibilityStatus": "PUBLISHED",
      "distributionStatus": "DISTRIBUTED",
      "publishingData": {
        "landingPageUrl": "https://www.example.com/so/SHORTCODE",
        "statistics": {
          "landingPage": {},
          "emailCampaign": {
            "delivered": 2,
            "opened": 2,
            "clicked": 2
          },
          "total": {
            "mailsSent": 2,
            "opened": 10,
            "clicked": 8
          }
        },
        "datePublished": "2020-02-14T14:28:54Z"
      },
      "dateCreated": "2020-02-13T11:18:30Z",
      "dateUpdated": "2020-02-14T14:28:19.680596102Z"
    }
  },
  "slug": "created",
  "id": "aacdffe0-8e14-4d1b-8060-8d0bf8248d36",
  "entityFqdn": "wix.email_marketing.v1.campaign",
  "eventTime": "2022-09-22T12:58:37.407664Z",
  "triggeredByAnonymizeRequest": false
}
```

---

## JavaScript SDK

### Schema

```
Webhook: onCampaignCreated
Description: Triggered when a campaign is created.
Payload: CampaignCreatedEnvelope
  - name: entity | type: Campaign | description: none
     - name: campaignId | type: string | description: Campaign 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.
     - 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.
        - 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.
           - name: dateResent | type: Date | description: Date and time the campaign was resent to the contacts it wasn't sent to.
  - name: metadata | type: EventMetadata | description: none
     - name: instanceId | type: string | description: App instance GUID.
     - name: eventType | type: string | description: Event type.
     - name: identity | type: IdentificationData | description: The identification type and identity data.
        - ONE-OF:
           - name: anonymousVisitorId | type: string | description: GUID of a site visitor that has not logged in to the site.
           - name: memberId | type: string | description: GUID of a site visitor that has logged in to the site.
           - name: wixUserId | type: string | description: GUID of a Wix user (site owner, contributor, etc.).
           - name: appId | type: string | description: GUID of an app.
        - name: identityType | type: WebhookIdentityType | description: 
             - enum: UNKNOWN, ANONYMOUS_VISITOR, MEMBER, WIX_USER, APP
     - name: accountInfo | type: AccountInfo | description: Details related to the account
        - name: accountId | type: string | description: GUID of the Wix account associated with the event.
        - name: parentAccountId | type: string | description: GUID of the parent Wix account. Only included when accountId belongs to a child account.
        - name: siteId | type: string | description: GUID of the Wix site associated with the event. Only included when the event is tied to a specific site.
     - name: _id | type: string | description: Event GUID. With this GUID you can easily spot duplicated events and ignore them.
     - name: entityFqdn | type: string | description: Fully Qualified Domain Name of an entity. This is a unique identifier assigned to the API main business entities. For example, `wix.stores.catalog.product`, `wix.bookings.session`, `wix.payments.transaction`.
     - name: slug | type: string | description: Event action name, placed at the top level to make it easier for users to dispatch messages. For example: `created`/`updated`/`deleted`/`started`/`completed`/`email_opened`.
     - name: entityId | type: string | description: GUID of the entity associated with the event.
     - name: eventTime | type: Date | description: Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example, `2020-04-26T13:57:50.699Z`.
     - name: triggeredByAnonymizeRequest | type: boolean | description: Whether the event was triggered as a result of a privacy regulation application (for example, GDPR).
     - name: originatedFrom | type: string | description: If present, indicates the action that triggered the event.
     - name: entityEventSequence | type: string | description: A sequence number that indicates the order of updates to an entity. For example, if an entity was updated at `16:00` and then again at `16:01`, the second update will always have a higher sequence number. You can use this number to make sure you're handling updates in the right order. Just save the latest sequence number on your end and compare it to the one in each new message. If the new message has an older (lower) number, you can safely ignore it.

```

### Examples


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

campaigns.onCampaignCreated((event) => {
    // handle your event here
});
```


```javascript
import { createClient, AppStrategy } from '@wix/sdk';
import { campaigns } from '@wix/email-marketing';

const wixClient = createClient({
  auth: AppStrategy({
    appId: 'MY-APP-ID',
    publicKey: 'YOUR_APP_PUBLIC_KEY',
  }),
  modules: {
      campaigns,
    },
});

wixClient.campaigns.onCampaignCreated((event) => {
    // handle your event here
});
```

---