# Write Display Condition

Creates or replaces a named email display condition and returns its decisionId. Choices come from get-email-editor-display-condition-capabilities; foreign entities are refused. Replacing a decisionId overwrites its segments and changes who sees bound rows in the draft, without undo. Bind a row with configure-email-editor-row-display-condition; this write alone shows nothing. Revision-bound, atomic edit; drafts only; publishing is publish-newsletter-email-content.

## Input schema:

```json
{
  "type": "object",
  "properties": {
    "editorUrl": {
      "type": "string",
      "description": "Editor URL of the email, as a read returned it",
      "minLength": 12,
      "maxLength": 500
    },
    "contentRevision": {
      "type": "string",
      "description": "The contentRevision of the read this change is based on",
      "minLength": 7,
      "maxLength": 100
    },
    "name": {
      "type": "string",
      "description": "What the editor shows for this condition; a person reads it",
      "minLength": 1,
      "maxLength": 250
    },
    "segments": {
      "type": "array",
      "description": "Each {conditions: [{conditionType, condition, entity, action, timeframe}], conditionsOpAND}; a contact matches a segment when its conditions match",
      "items": {
        "type": "object",
        "properties": {
          "conditionsOpAND": {
            "type": "boolean"
          },
          "conditions": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "object",
              "properties": {
                "conditionType": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 250
                },
                "condition": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100
                },
                "entity": {
                  "type": "integer",
                  "minimum": 1
                },
                "action": {
                  "type": "string",
                  "maxLength": 100
                },
                "timeframe": {
                  "type": "string",
                  "maxLength": 100
                }
              },
              "required": [
                "conditionType",
                "condition"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "conditions"
        ],
        "additionalProperties": false
      },
      "minItems": 1,
      "maxItems": 10
    },
    "segmentsOpAND": {
      "type": [
        "null",
        "boolean"
      ],
      "description": "true when every segment has to match, false when one is enough; defaults to true",
      "default": null
    },
    "decisionId": {
      "type": [
        "null",
        "string"
      ],
      "description": "decisionId of an existing condition to replace whole; omit to create one",
      "default": null,
      "maxLength": 50
    },
    "description": {
      "type": [
        "null",
        "string"
      ],
      "description": "A note for the person editing this email later",
      "default": null,
      "maxLength": 1000
    },
    "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",
    "name",
    "segments"
  ],
  "additionalProperties": false
}
```

## Output schema:

```json
{
  "type": "object",
  "oneOf": [
    {
      "type": "object",
      "required": [
        "operation",
        "previousContentStatus",
        "contentStatus",
        "emailId",
        "contentRevision",
        "warnings",
        "editorUrl",
        "nextAction",
        "created"
      ],
      "properties": {
        "operation": {
          "type": "string",
          "enum": [
            "replaced",
            "unchanged"
          ],
          "description": "\"replaced\": the stored document is a new one; \"unchanged\": nothing was persisted."
        },
        "previousContentStatus": {
          "type": "string",
          "enum": [
            "draft",
            "published",
            "unpublished_changes"
          ]
        },
        "contentStatus": {
          "type": "string",
          "enum": [
            "draft",
            "published",
            "unpublished_changes"
          ]
        },
        "emailId": {
          "type": "integer"
        },
        "contentRevision": {
          "type": "string"
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "editorUrl": {
          "type": "string"
        },
        "created": {
          "type": "array",
          "description": "What this write created, with uuids: after \"addRow\" the row and its columns, after \"addModule\" the block, plus the contentRevision the next write needs. Empty when nothing was created.",
          "items": {
            "type": "object",
            "required": [
              "operation",
              "type",
              "uuid"
            ],
            "properties": {
              "operation": {
                "type": "integer",
                "description": "Position of the creating operation in the request, counted from one."
              },
              "type": {
                "type": "string",
                "enum": [
                  "row",
                  "module"
                ]
              },
              "uuid": {
                "type": "string"
              },
              "kind": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The block kind, for a module."
              },
              "columns": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Uuids of the columns of a new row, in order; an \"addModule\" addresses one of these."
              }
            }
          }
        },
        "nextAction": {
          "type": "string",
          "enum": [
            "review_and_publish_content",
            "none"
          ],
          "description": "The content action still open: \"review_and_publish_content\" while the stored draft is not the dispatch content."
        }
      }
    },
    {
      "type": "object",
      "required": [
        "error"
      ],
      "properties": {
        "error": {
          "type": "object",
          "required": [
            "code",
            "message",
            "remediation",
            "details"
          ],
          "properties": {
            "code": {
              "type": "string",
              "description": "The machine-readable KlickTipp error code."
            },
            "message": {
              "type": "string"
            },
            "remediation": {
              "type": "string",
              "description": "Who has to act: for example get_again, use_klicktipp_editor, change_document, change_html, retry_later or ask_user_before_retry."
            },
            "details": {
              "type": "object"
            }
          }
        }
      }
    }
  ]
}
```

