# Replace Rich-Text Email Content

Replaces the whole body of a KlickTipp newsletter email built with the previous HTML editor. No undo, no publish step: what is stored is what a dispatch sends. Always the complete body -- read it with get-email-editor-rich-text-content, change it and send all of it back. Bound to that read's contentRevision, so a newsletter changed meanwhile is refused. HTML is held to the editor's check and refused with the position of the first unsupported markup. Needs a subject already (else ErrorNoSubject); subject, name, sender and audience stay untouched. A plain text passed in is kept only if the account maintains plain text itself, else it is generated and warnings say so. Drag-and-drop emails belong to the block tools. The editorUrl returned is not a link to open in KlickTipp; use contentUrl from get-newsletter for that.

## Input schema:

```json
{
  "type": "object",
  "properties": {
    "editorUrl": {
      "type": "string",
      "description": "Editor URL of the email, as get-email-editor-content returned it",
      "minLength": 12,
      "maxLength": 500
    },
    "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"
      ]
    },
    "accountId": {
      "type": [
        "null",
        "integer"
      ],
      "description": "User ID of the account; omit for the account the access token works in",
      "default": null,
      "minimum": 1
    }
  },
  "required": [
    "editorUrl",
    "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
}
```

