# Replace Rich-Text Email Content

Replaces a rich-text email’s entire body (newsletter, automation or notification; by email ID or editor URL) without undo or a publish step; the stored body is what dispatch sends. Requires a subject and the current contentRevision from get-email-editor-rich-text-content. HTML is stored only as KlickTipp normalises it: no html, head, body or script, self-closed <br />, closed <p> and <li>; a refusal names the place and the fix. Plain text is retained only when the account maintains it, otherwise generated with a warning. Subject, sender and audience stay. Like the app, an email an active automation uses is written too. Drag-and-drop emails are refused.

## Input schema:

```json
{
  "type": "object",
  "properties": {
    "contentRevision": {
      "type": "string",
      "description": "contentRevision of the preceding get-email-editor-rich-text-content; a stale one refuses the write",
      "minLength": 7,
      "maxLength": 100
    },
    "html": {
      "type": "string",
      "description": "Complete HTML body, at most what a read hands back; pass an empty string only with contentType \"plain-only\"",
      "maxLength": 100000
    },
    "plain": {
      "type": [
        "null",
        "string"
      ],
      "description": "Complete plain-text body, kept only if the account maintains plain text itself (else generated from the HTML, with a warning); omit to have KlickTipp generate it",
      "default": null,
      "maxLength": 100000
    },
    "contentType": {
      "type": [
        "null",
        "string"
      ],
      "description": "\"html-and-plain\" or \"plain-only\"; omit to keep what the email uses",
      "default": null,
      "enum": [
        "html-and-plain",
        "plain-only"
      ]
    },
    "emailId": {
      "type": [
        "null",
        "integer"
      ],
      "description": "ID of the email; omit when the editor URL is given",
      "default": null,
      "minimum": 1
    },
    "editorUrl": {
      "type": [
        "null",
        "string"
      ],
      "description": "Editor URL of the email, as get-email-editor-content returned it; omit when the email ID is given",
      "default": null,
      "minLength": 12,
      "maxLength": 500
    },
    "accountId": {
      "type": [
        "null",
        "integer"
      ],
      "description": "User ID of the account; omit for the account the access token works in",
      "default": null,
      "minimum": 1
    }
  },
  "required": [
    "contentRevision",
    "html"
  ],
  "additionalProperties": false
}
```

## Output schema:

```json
{
  "type": "object",
  "required": [
    "operation",
    "accountId",
    "emailId",
    "contentType",
    "plainSource",
    "contentRevision",
    "editorUrl",
    "warnings"
  ],
  "properties": {
    "operation": {
      "type": "string",
      "enum": [
        "replaced",
        "unchanged"
      ]
    },
    "accountId": {
      "type": "integer"
    },
    "emailId": {
      "type": "integer"
    },
    "contentType": {
      "type": "string",
      "enum": [
        "html-and-plain",
        "plain-only"
      ]
    },
    "plainSource": {
      "type": "string",
      "enum": [
        "derived",
        "custom"
      ]
    },
    "contentRevision": {
      "type": "string"
    },
    "editorUrl": {
      "type": "string",
      "description": "Names this email for the tools; not a link to open in KlickTipp. To show the email to a person, use contentUrl from get-newsletter."
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "additionalProperties": false
}
```

