# Add Email Action

Adds an automation email action that sends a referenced email (emailID, created with create-automation-email-draft) when the contact reaches it. emailID may be left out or 0, as in the app, to build the steps first and write the emails later; do not create empty emails for that. validate-automation reports a step without an email, and the automation cannot be activated until each has one. Editing the shared email affects every action that references it. Requires an unscheduled, inactive automation and its current revision from get-automation; dryRun previews without saving. Place it with afterActionId and branch (next after a regular action, yes/no after a decision).

## Input schema:

```json
{
  "type": "object",
  "properties": {
    "automationId": {
      "type": "integer",
      "minimum": 1
    },
    "revision": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "afterActionId": {
      "type": "integer",
      "minimum": 1
    },
    "branch": {
      "type": "string",
      "enum": [
        "next",
        "yes",
        "no"
      ]
    },
    "settings": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "success_tag_id": {
          "type": "integer",
          "minimum": 0,
          "description": "Only for an email with AI-generated content: manual tag set when generating the content succeeded; 0 for none. Not used for other emails."
        },
        "error_tag_id": {
          "type": "integer",
          "minimum": 0,
          "description": "Only for an email with AI-generated content: manual tag set when generating the content failed or timed out; 0 for none. Not used for other emails."
        },
        "name": {
          "type": "string",
          "maxLength": 250
        },
        "color": {
          "type": "string",
          "enum": [
            "",
            "teal-light",
            "peach-light",
            "pink-light",
            "violet-light",
            "blue-light",
            "silver-light",
            "brown-light",
            "yellow-light",
            "green-light",
            "coldgreen-light",
            "teal-dark",
            "peach-dark",
            "pink-dark",
            "violet-dark",
            "blue-dark",
            "silver-dark",
            "brown-dark",
            "yellow-dark",
            "green-dark",
            "coldgreen-dark"
          ],
          "description": "Card colour from the editor palette, e.g. green-dark or blue-light. An empty string uses the default colour of the action type."
        },
        "emailID": {
          "type": "integer",
          "minimum": 0,
          "description": "Email sent by this step; 0 for none yet, which the automation reports and which keeps it from being activated."
        },
        "ignoreSubscriberStatus": {
          "type": "integer",
          "enum": [
            0,
            1
          ]
        }
      },
      "required": []
    },
    "dryRun": {
      "type": "boolean",
      "default": false
    },
    "accountId": {
      "type": [
        "null",
        "integer"
      ],
      "default": null,
      "minimum": 1
    }
  },
  "required": [
    "automationId",
    "revision",
    "afterActionId",
    "branch",
    "settings"
  ],
  "additionalProperties": false
}
```

## Output schema:

```json
{
  "type": "object",
  "required": [
    "automationId",
    "name",
    "revision",
    "status",
    "editorUrl",
    "graph",
    "findings",
    "editable",
    "dryRun",
    "settings",
    "splitTests"
  ],
  "properties": {
    "automationId": {
      "type": "integer"
    },
    "name": {
      "type": "string"
    },
    "revision": {
      "type": "string"
    },
    "status": {
      "type": "string"
    },
    "editorUrl": {
      "type": "string"
    },
    "graph": {
      "type": "object",
      "required": [
        "start",
        "goals",
        "states"
      ],
      "properties": {
        "start": {
          "type": "integer"
        },
        "goals": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        },
        "states": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "type",
              "next",
              "nextNo"
            ],
            "properties": {
              "id": {
                "type": "integer"
              },
              "type": {
                "type": "string"
              },
              "next": {
                "type": "integer"
              },
              "nextNo": {
                "type": "integer"
              }
            },
            "additionalProperties": true
          }
        }
      }
    },
    "findings": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "actionId",
          "code",
          "message",
          "warning",
          "variantId"
        ],
        "properties": {
          "actionId": {
            "type": "integer"
          },
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "warning": {
            "type": "boolean"
          },
          "variantId": {
            "type": "integer"
          }
        }
      }
    },
    "editable": {
      "type": "boolean"
    },
    "dryRun": {
      "type": "boolean"
    },
    "settings": {
      "type": [
        "object",
        "array"
      ]
    },
    "splitTests": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "actionId",
          "id"
        ],
        "properties": {
          "actionId": {
            "type": "integer"
          },
          "id": {
            "type": "integer"
          },
          "missing": {
            "type": "boolean"
          },
          "revision": {
            "type": [
              "string",
              "null"
            ]
          },
          "durationSeconds": {
            "type": "integer"
          },
          "started": {
            "type": "integer"
          },
          "finished": {
            "type": "integer"
          },
          "winnerIndex": {
            "type": "integer"
          },
          "variants": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "kind",
                "entityId",
                "weight",
                "goalTagId"
              ],
              "properties": {
                "kind": {
                  "type": "string"
                },
                "entityId": {
                  "type": "integer"
                },
                "weight": {
                  "type": "integer"
                },
                "goalTagId": {
                  "type": "integer"
                },
                "contactCount": {
                  "type": "integer"
                },
                "conversionCount": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    }
  }
}
```

