> 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

# UpdateComposer

# Package: emailMarketing

# Namespace: CampaignService

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

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

## Introduction

Updates a campaign's editor data, including the content and subject line.

Set `campaignEditorType.value` to the campaign's `editorType`, which [Get Campaign](https://dev.wix.com/docs/api-reference/business-management/marketing/emails/email-marketing/campaign/get-campaign.md)
returns, and pass `composerDataJson` in the matching format. Don't change a campaign's editor type,
except that you can update a `MOBILE` campaign with `WEB`. If `composerDataJson` doesn't match the
editor type, the campaign can't be sent or previewed correctly.

An MJML document uses `mjml` and `mj-body`, and may include `mj-head`. For MJML syntax, see
the [MJML documentation](https://documentation.mjml.io/). Within that document structure,
AI Composer can fully edit these components:

- Layout: `mj-section`, `mj-column`, `mj-group`, `mj-wrapper`, `mj-hero`.
- Content: `mj-text`, `mj-image`, `mj-button`, `mj-divider`, `mj-spacer`, `mj-social`.
- Head: `mj-attributes`, `mj-class`, `mj-all`, `mj-font`, `mj-style`, `mj-breakpoint`,
`mj-preview`, `mj-title`.

Inside `mj-text`, AI Composer supports simple formatting: paragraphs, headings (`h1` to `h3`),
lists, links, bold, italic, underline, and colors. Other MJML layout, content, and head components
aren't supported for editing. Some, including `mj-accordion`, `mj-carousel`, `mj-navbar`, and `mj-raw`, may render, but
AI Composer can only duplicate or delete them. Avoid `mj-table`: opening it in AI Composer removes
its rows and turns the table into a single line of text.

---

## REST API

### Schema

```
 Method: updateComposer
 Description: Updates a campaign's editor data, including the content and subject line.  Set `campaignEditorType.value` to the campaign's `editorType`, which [Get Campaign](https://dev.wix.com/docs/api-reference/business-management/marketing/emails/email-marketing/campaign/get-campaign.md) returns, and pass `composerDataJson` in the matching format. Don't change a campaign's editor type, except that you can update a `MOBILE` campaign with `WEB`. If `composerDataJson` doesn't match the editor type, the campaign can't be sent or previewed correctly.  An MJML document uses `mjml` and `mj-body`, and may include `mj-head`. For MJML syntax, see the [MJML documentation](https://documentation.mjml.io/). Within that document structure, AI Composer can fully edit these components:  - Layout: `mj-section`, `mj-column`, `mj-group`, `mj-wrapper`, `mj-hero`. - Content: `mj-text`, `mj-image`, `mj-button`, `mj-divider`, `mj-spacer`, `mj-social`. - Head: `mj-attributes`, `mj-class`, `mj-all`, `mj-font`, `mj-style`, `mj-breakpoint`, `mj-preview`, `mj-title`.  Inside `mj-text`, AI Composer supports simple formatting: paragraphs, headings (`h1` to `h3`), lists, links, bold, italic, underline, and colors. Other MJML layout, content, and head components aren't supported for editing. Some, including `mj-accordion`, `mj-carousel`, `mj-navbar`, and `mj-raw`, may render, but AI Composer can only duplicate or delete them. Avoid `mj-table`: opening it in AI Composer removes its rows and turns the table into a single line of text.
 URL: https://www.wixapis.com/email-marketing/v1/campaigns/{campaignId}/composer
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  composer.composerDataJson
 Method parameters: 
   param name: campaignEditorType | type: CampaignEditorType | description: Editor type.  
        - name: value | type: Enum | description:   
             - 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.
   param name: composer | type: Composer | description: Represents a campaign's editor data that is used to render the campaign in the editor and viewer.  
        - name: composerDataJson | type: string | description: Editor content for the campaign. The format depends on `campaignEditorType`:  - `WEB`: Wix proprietary JSON format used by the drag-and-drop email editor. - `MOBILE`: A subset of the `WEB` format, used by the mobile email editor. - `MJML`: MJML markup wrapped in a JSON object under key "mjml". - `HTML`: HTML code wrapped in a JSON object under key "html".  Passing the wrong format for the given `campaignEditorType` causes a silent failure when sending or previewing the campaign. | required: true | validation: maxLength 10000000
        - name: defaultValues | type: DefaultValues | description: Fallback values for dynamic placeholders in the campaign content.  
           - name: map | type: object | description: Map of placeholder keys to their default values.  | validation: maxItems 500, format map
   param name: emailPreheader | type: emailPreheader | description: Short preview text shown after the subject line in some email clients (optional).  | validation: maxLength 1000
   param name: emailSubject | type: emailSubject | description: Subject line displayed in recipients' inboxes (optional).  | validation: maxLength 1000
 Return type: UpdateComposerResponse
  EMPTY-OBJECT {}


```

### Examples

### Update Composer
Update an HTML campaign's editor data and subject line. `campaignEditorType.value` must match the campaign's `editorType` from Get Campaign.

```curl
curl -X POST \
'https://www.wixapis.com/email-marketing/v1/campaigns/943602e1-633b-4577-ab39-43cba3dc17aa/composer' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "composer": {
    "composerDataJson": "{\"html\":\"<!doctype html><html><body><table align=\\\"center\\\" width=\\\"700\\\"><tr><td style=\\\"padding:24px;font-family:Arial,sans-serif;\\\">Summer Sale Extended! Get 25% off all products.</td></tr></table></body></html>\"}"
  },
  "campaignEditorType": {
    "value": "HTML"
  },
  "emailSubject": "Summer Sale Extended - 25% Off Everything",
  "emailPreheader": "We extended our sale just for you"
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.emailMarketing.campaigns.updateComposer(campaignId, options)
 Description: Updates a campaign's editor data, including the content and subject line.  Set `campaignEditorType.value` to the campaign's `editorType`, which [Get Campaign](https://dev.wix.com/docs/api-reference/business-management/marketing/emails/email-marketing/campaign/get-campaign.md) returns, and pass `composerDataJson` in the matching format. Don't change a campaign's editor type, except that you can update a `MOBILE` campaign with `WEB`. If `composerDataJson` doesn't match the editor type, the campaign can't be sent or previewed correctly.  An MJML document uses `mjml` and `mj-body`, and may include `mj-head`. For MJML syntax, see the [MJML documentation](https://documentation.mjml.io/). Within that document structure, AI Composer can fully edit these components:  - Layout: `mj-section`, `mj-column`, `mj-group`, `mj-wrapper`, `mj-hero`. - Content: `mj-text`, `mj-image`, `mj-button`, `mj-divider`, `mj-spacer`, `mj-social`. - Head: `mj-attributes`, `mj-class`, `mj-all`, `mj-font`, `mj-style`, `mj-breakpoint`, `mj-preview`, `mj-title`.  Inside `mj-text`, AI Composer supports simple formatting: paragraphs, headings (`h1` to `h3`), lists, links, bold, italic, underline, and colors. Other MJML layout, content, and head components aren't supported for editing. Some, including `mj-accordion`, `mj-carousel`, `mj-navbar`, and `mj-raw`, may render, but AI Composer can only duplicate or delete them. Avoid `mj-table`: opening it in AI Composer removes its rows and turns the table into a single line of text.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  campaignId, options.composer.composerDataJson
 Method parameters: 
   param name: campaignId | type: string | description: Campaign GUID. | required: true | validation: format GUID
   param name: options | type: UpdateComposerOptions  none  
        - name: composer | type: Composer | description: Updated campaign editor data.  
           - name: composerDataJson | type: string | description: Editor content for the campaign. The format depends on `campaignEditorType`:  - `WEB`: Wix proprietary JSON format used by the drag-and-drop email editor. - `MOBILE`: A subset of the `WEB` format, used by the mobile email editor. - `MJML`: MJML markup wrapped in a JSON object under key "mjml". - `HTML`: HTML code wrapped in a JSON object under key "html".  Passing the wrong format for the given `campaignEditorType` causes a silent failure when sending or previewing the campaign. | required: true | validation: maxLength 10000000
           - name: defaultValues | type: DefaultValues | description: Fallback values for dynamic placeholders in the campaign content.  
              - name: map | type: object | description: Map of placeholder keys to their default values.  | validation: maxItems 500, format map
        - name: campaignEditorType | type: CampaignEditorType | description: Editor type of the campaign. Determines how `composer.composerDataJson` is parsed and stored.  Set `campaignEditorType.value` to the campaign's `editorType`, which [Get Campaign](https://dev.wix.com/docs/api-reference/business-management/marketing/emails/email-marketing/campaign/get-campaign.md) returns. Don't change a campaign's editor type, except that you can update a `MOBILE` campaign with `WEB`.  Default: `WEB`  
           - name: value | type: Enum | description:   
                 - 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: emailSubject | type: string | description: Subject line displayed in recipients' inboxes (optional).  | validation: maxLength 1000
        - name: emailPreheader | type: string | description: Short preview text shown after the subject line in some email clients (optional).  | validation: maxLength 1000
 Return type: PROMISE<UpdateComposerResponse>
  EMPTY-OBJECT {}


```

### Examples

### Update a campaign's editor data
Updates the composer data, subject line, and preheader for a campaign.

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

export async function updateComposer(campaignId) {
  await campaigns.updateComposer(
    campaignId,
    {
      composer: {
        composerDataJson: "{\"html\":\"<!doctype html><html><body><table align=\\\"center\\\" width=\\\"700\\\"><tr><td style=\\\"padding:24px;font-family:Arial,sans-serif;\\\">Summer Sale Extended! Get 25% off all products.</td></tr></table></body></html>\"}",
      },
      // Use the campaign's editorType from getCampaign(). This example updates an HTML campaign.
      campaignEditorType: { value: "HTML" },
      emailSubject: "Summer Sale Extended - 25% Off Everything",
      emailPreheader: "We extended our sale just for you",
    },
  );
}

```

### updateComposer (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 updateComposer(campaignId,options) {
  const response = await myWixClient.campaigns.updateComposer(campaignId,options);
};
```

---