# Delete Automation

Deletes an automation that is neither active nor scheduled, including waiting contacts, statistics, system tags and goal history, without undo. With contact history the first call is refused with counts; repeat with deleteContactHistory=true. Other dependencies block deletion. Referenced emails remain. Stop an active automation first with stop-automation.

## Input schema:

```json
{
  "type": "object",
  "properties": {
    "automationId": {
      "type": "integer",
      "description": "ID of the automation to delete",
      "minimum": 1
    },
    "revision": {
      "type": "string",
      "description": "Current revision from get-automation",
      "pattern": "^[a-f0-9]{64}$"
    },
    "confirm": {
      "type": "boolean",
      "description": "true only when the user asked to delete this automation",
      "default": false
    },
    "deleteContactHistory": {
      "type": "boolean",
      "description": "true only after the user agreed to lose its contact history; the first refusal names it",
      "default": false
    },
    "accountId": {
      "type": [
        "null",
        "integer"
      ],
      "description": "User ID of the account; omit for the account of the access token",
      "default": null,
      "minimum": 1
    }
  },
  "required": [
    "automationId",
    "revision"
  ],
  "additionalProperties": false
}
```

## Output schema:

```json
{
  "type": "object",
  "required": [
    "accountId",
    "automationId",
    "deleted",
    "startedContacts",
    "finishedContacts",
    "activeContacts"
  ],
  "properties": {
    "accountId": {
      "type": "integer"
    },
    "automationId": {
      "type": "integer"
    },
    "deleted": {
      "type": "boolean"
    },
    "startedContacts": {
      "type": "integer"
    },
    "finishedContacts": {
      "type": "integer"
    },
    "activeContacts": {
      "type": "integer"
    }
  }
}
```

