> 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

# SetEmailContent

# Package: emails

# Namespace: AutomationEmailActionsService

# Method link: https://dev.wix.com/docs/api-reference/business-management/marketing/emails/automation-email-action/set-email-content.md

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

## Introduction

Updates the email content of an automation's send email action.

The content is replaced in full, and is live for subsequent runs of the automation once the
call returns. Replaced in full means anything left out of `content` is cleared, so omitting the
preview text or a default placeholder value removes it rather than keeping what was stored. The
one exception is `editorType`, which describes the content type rather than being part of it.

This operation doesn't preserve drafts: after the update, the message and every existing draft
translation are published and become live.

There's no revision to pass and no concurrency check: the last write wins, and two callers
updating the same email at once will silently overwrite one another.

The most reliable way to update content is to first retrieve it with [Get Email Content](https://dev.wix.com/docs/api-reference/business-management/marketing/emails/automation-email-action/get-email-content.md)
and modify the result, rather than building `content` from scratch. `composer.composerDataJson` is a
proprietary structure, and an invalid value can prevent the content from being previewed or sent.

---

## REST API

### Schema

```
 Method: setEmailContent
 Description: Updates the email content of an automation's send email action.  The content is replaced in full, and is live for subsequent runs of the automation once the call returns. Replaced in full means anything left out of `content` is cleared, so omitting the preview text or a default placeholder value removes it rather than keeping what was stored. The one exception is `editorType`, which describes the content type rather than being part of it.  This operation doesn't preserve drafts: after the update, the message and every existing draft translation are published and become live.  There's no revision to pass and no concurrency check: the last write wins, and two callers updating the same email at once will silently overwrite one another.  The most reliable way to update content is to first retrieve it with [Get Email Content](https://dev.wix.com/docs/api-reference/business-management/marketing/emails/automation-email-action/get-email-content.md) and modify the result, rather than building `content` from scratch. `composer.composerDataJson` is a proprietary structure, and an invalid value can prevent the content from being previewed or sent.
 URL: https://www.wixapis.com/emails-automations/v1/automations/{automationId}/email-actions/{actionId}/email-content
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  content, content.emailSubject, content.composer, content.composer.composerDataJson
 Method parameters: 
   param name: content | type: AutomationEmailContent | description: Email content of a send email action. | required: true 
        - name: emailSubject | type: string | description: Subject line displayed in recipients' inboxes. | required: true | validation: maxLength 1000
        - name: emailPreheader | type: string | description: Short preview text shown after the subject line in some email clients.  | validation: maxLength 1000
        - name: composer | type: Composer | description: Editor content and placeholder fallback values, using the canonical Email Marketing [Composer](https://dev.wix.com/docs/api-reference/business-management/marketing/emails/email-marketing/campaign/update-composer.md) contract. | required: true 
           - 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: editorType | type: Enum | description: Editor type that produced `composer.composerDataJson`, and therefore the format that field is in. Set it whenever the content being written is in a different format than what is stored - the renderer picks its path from this, and a mismatch fails silently when previewing or sending. Leaving it unset on update keeps existing type.  Automations support `WEB` and `MJML`.  
             - 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: language | type: language | description: Language to update the content in. Defaults to the site's primary language.  | validation: format LANGUAGE
 Return type: SetEmailContentResponse
  - name: content | type: AutomationEmailContent | description: Email content after update.  
     - name: emailSubject | type: string | description: Subject line displayed in recipients' inboxes.  | validation: maxLength 1000
     - name: emailPreheader | type: string | description: Short preview text shown after the subject line in some email clients.  | validation: maxLength 1000
     - name: composer | type: Composer | description: Editor content and placeholder fallback values, using the canonical Email Marketing [Composer](https://dev.wix.com/docs/api-reference/business-management/marketing/emails/email-marketing/campaign/update-composer.md) contract.  
        - 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.  | 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: editorType | type: Enum | description: Editor type that produced `composer.composerDataJson`, and therefore the format that field is in. Set it whenever the content being written is in a different format than what is stored - the renderer picks its path from this, and a mismatch fails silently when previewing or sending. Leaving it unset on update keeps existing type.  Automations support `WEB` and `MJML`.  
         - 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.

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: LANGUAGE_NOT_CONFIGURED_FOR_SITE | Description: none
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: NOT_AN_EMAIL_ACTION | Description: none
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: CONTENT_NOT_PUBLISHABLE | Description: The submitted content isn't in a publishable state.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: AUTOMATION_ACTION_NOT_FOUND | Description: none
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CONTENT_NOT_CONFIGURED | Description: none


```

### Examples

### Set Email Content
Update the email content of an automation's send email action.

```curl
curl -X POST \
'https://www.wixapis.com/emails-automations/v1/automations/0029458c-a8e1-4d04-bd88-ad0af11cb678/email-actions/f6f72a5c-77ef-4672-ada1-83aa45de7f2c/email-content' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "content": {
    "emailSubject": "Changes to your ${subscriptionName} subscription price",
    "emailPreheader": "Your subscription price is changing",
    "composer": {
      "composerDataJson": "{\"regions\":[{\"type\":\"text\",\"data\":{\"html\":\"<p>Changes to your <bdi>${subscriptionName}</bdi> subscription price</p>\"}}]}",
      "defaultValues": {
        "map": {
          "subscriptionName": "",
          "priceUpdateDate": "",
          "itemUpdatedPrice": "",
          "cycleType": ""
        }
      }
    },
    "editorType": "WEB"
  }
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.automationsEmailActions.automationEmailAction.setEmailContent(identifiers, options)
 Description: Updates the email content of an automation's send email action.  The content is replaced in full, and is live for subsequent runs of the automation once the call returns. Replaced in full means anything left out of `content` is cleared, so omitting the preview text or a default placeholder value removes it rather than keeping what was stored. The one exception is `editorType`, which describes the content type rather than being part of it.  This operation doesn't preserve drafts: after the update, the message and every existing draft translation are published and become live.  There's no revision to pass and no concurrency check: the last write wins, and two callers updating the same email at once will silently overwrite one another.  The most reliable way to update content is to first retrieve it with [Get Email Content](https://dev.wix.com/docs/api-reference/business-management/marketing/emails/automation-email-action/get-email-content.md) and modify the result, rather than building `content` from scratch. `composer.composerDataJson` is a proprietary structure, and an invalid value can prevent the content from being previewed or sent.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  identifiers.automationId, identifiers.actionId, options.content, options.content.emailSubject, options.content.composer, options.content.composer.composerDataJson, identifiers, options
 Method parameters: 
   param name: identifiers | type: SetEmailContentIdentifiers  none | required: true 
        - name: automationId | type: string | description: GUID of the automation the action belongs to. | required: true | validation: format GUID
        - name: actionId | type: string | description: GUID of the send email action within the automation. | required: true | validation: format GUID
   param name: options | type: SetEmailContentOptions  none | required: true 
        - name: language | type: string | description: Language to update the content in. Defaults to the site's primary language.  | validation: format LANGUAGE
        - name: content | type: AutomationEmailContent | description: Email content to store. Replaces the stored content in full - see the method description. | required: true 
           - name: emailSubject | type: string | description: Subject line displayed in recipients' inboxes. | required: true | validation: maxLength 1000
           - name: emailPreheader | type: string | description: Short preview text shown after the subject line in some email clients.  | validation: maxLength 1000
           - name: composer | type: Composer | description: Editor content and placeholder fallback values, using the canonical Email Marketing [Composer](https://dev.wix.com/docs/api-reference/business-management/marketing/emails/email-marketing/campaign/update-composer.md) contract. | required: true 
              - 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: editorType | type: Enum | description: Editor type that produced `composer.composerDataJson`, and therefore the format that field is in. Set it whenever the content being written is in a different format than what is stored - the renderer picks its path from this, and a mismatch fails silently when previewing or sending. Leaving it unset on update keeps existing type.  Automations support `WEB` and `MJML`.  
                 - 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.
 Return type: PROMISE<SetEmailContentResponse>
  - name: content | type: AutomationEmailContent | description: Email content after update.  
     - name: emailSubject | type: string | description: Subject line displayed in recipients' inboxes.  | validation: maxLength 1000
     - name: emailPreheader | type: string | description: Short preview text shown after the subject line in some email clients.  | validation: maxLength 1000
     - name: composer | type: Composer | description: Editor content and placeholder fallback values, using the canonical Email Marketing [Composer](https://dev.wix.com/docs/api-reference/business-management/marketing/emails/email-marketing/campaign/update-composer.md) contract.  
        - 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.  | 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: editorType | type: Enum | description: Editor type that produced `composer.composerDataJson`, and therefore the format that field is in. Set it whenever the content being written is in a different format than what is stored - the renderer picks its path from this, and a mismatch fails silently when previewing or sending. Leaving it unset on update keeps existing type.  Automations support `WEB` and `MJML`.  
         - 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.

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: LANGUAGE_NOT_CONFIGURED_FOR_SITE | Description: none
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: NOT_AN_EMAIL_ACTION | Description: none
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: CONTENT_NOT_PUBLISHABLE | Description: The submitted content isn't in a publishable state.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: AUTOMATION_ACTION_NOT_FOUND | Description: none
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CONTENT_NOT_CONFIGURED | Description: none


```

### Examples

### Set email content
Update the email content of an automation's send email action.

```javascript
import { automationEmailAction } from "@wix/automations-email-actions";

async function setEmailContent() {
  const response = await automationEmailAction.setEmailContent(
    {
      automationId: "0029458c-a8e1-4d04-bd88-ad0af11cb678",
      actionId: "f6f72a5c-77ef-4672-ada1-83aa45de7f2c",
    },
    {
      content: {
        emailSubject: "Changes to your ${subscriptionName} subscription price",
        emailPreheader: "Your subscription price is changing",
        composer: {
          composerDataJson: "{\"regions\":[{\"type\":\"text\",\"data\":{\"html\":\"<p>Changes to your <bdi>${subscriptionName}</bdi> subscription price</p>\"}}]}",
          defaultValues: {
            map: {
              subscriptionName: "",
              priceUpdateDate: "",
              itemUpdatedPrice: "",
              cycleType: "",
            },
          },
        },
        editorType: "WEB",
      },
    },
  );
}

/* Promise resolves to:
 * {
 *   "content": {
 *     "emailSubject": "Changes to your ${subscriptionName} subscription price",
 *     "emailPreheader": "Your subscription price is changing",
 *     "composer": {
 *       "composerDataJson": "{\"regions\":[{\"type\":\"text\",\"data\":{\"html\":\"<p>Changes to your <bdi>${subscriptionName}</bdi> subscription price</p>\"}}]}",
 *       "defaultValues": {
 *         "map": {
 *           "subscriptionName": "",
 *           "priceUpdateDate": "",
 *           "itemUpdatedPrice": "",
 *           "cycleType": ""
 *         }
 *       }
 *     },
 *     "editorType": "WEB"
 *   }
 * }
 */

```

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

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


async function setEmailContent(identifiers,options) {
  const response = await myWixClient.automationEmailAction.setEmailContent(identifiers,options);
};
```

---