{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/elocuenti-com/json-schema/elocuenti-com-automation-run-response-schema.json",
  "title": "AutomationRunResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/elocuenti-com-automations-api-openapi.yml#/components/schemas/AutomationRunResponse",
  "type": "object",
  "properties": {
    "data": {
      "$ref": "#/$defs/AutomationRun"
    },
    "request_id": {
      "type": "string",
      "description": "The identifier of this request. Give it to support if you need help.",
      "title": "Request Id"
    }
  },
  "required": [
    "data",
    "request_id"
  ],
  "$defs": {
    "AutomationRun": {
      "type": "object",
      "properties": {
        "run_id": {
          "type": "string",
          "description": "The identifier of the run.",
          "title": "Run Id"
        },
        "automation_id": {
          "type": "string",
          "description": "The automation.",
          "title": "Automation Id"
        },
        "contact_id": {
          "type": "string",
          "description": "The contact the run is for.",
          "title": "Contact Id"
        },
        "status": {
          "type": "string",
          "enum": [
            "queued",
            "running",
            "waiting",
            "completed",
            "failed",
            "cancelled"
          ],
          "description": "`queued`: accepted, waiting for the platform to take it. `running`: taken and working (a long first step reads `running`, not `queued`). `waiting`: paused on a delay or until the customer answers. `completed`: finished. `failed`: stopped by a step that failed. `cancelled`: stopped before the end.",
          "title": "Status"
        },
        "created_at": {
          "type": "string",
          "description": "When the run was accepted (UTC, ISO 8601).",
          "title": "Created At"
        },
        "finished_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "When the run ended (UTC, ISO 8601). `null` while it has not ended.",
          "title": "Finished At"
        },
        "steps": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AutomationRunStep"
          },
          "description": "The steps that have run, in order (up to 50). Empty while the run is `queued`.",
          "title": "Steps"
        },
        "error": {
          "anyOf": [
            {
              "$ref": "#/$defs/AutomationRunError"
            },
            {
              "type": "null"
            }
          ],
          "description": "Only when `status` is `failed` or `cancelled`; `null` otherwise."
        }
      },
      "required": [
        "run_id",
        "automation_id",
        "contact_id",
        "status",
        "created_at",
        "finished_at",
        "steps",
        "error"
      ],
      "description": "How a run is going, or how it went.",
      "title": "AutomationRun"
    },
    "AutomationRunError": {
      "type": "object",
      "properties": {
        "reason": {
          "type": "string",
          "enum": [
            "no_conversation",
            "messaging_window_closed",
            "contact_opted_out",
            "template_unavailable",
            "missing_data",
            "automation_disabled",
            "contact_changed",
            "cancelled",
            "could_not_run",
            "step_failed"
          ],
          "description": "Why the run did not complete: one of a fixed list. See the description of the operation.",
          "title": "Reason"
        },
        "message": {
          "type": "string",
          "description": "The reason in words, in English. The text does not change per run and never names your customers.",
          "title": "Message"
        }
      },
      "required": [
        "reason",
        "message"
      ],
      "description": "Why a run failed or was cancelled.",
      "title": "AutomationRunError"
    },
    "AutomationRunStep": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "action",
            "delay",
            "condition",
            "wait_for_response"
          ],
          "description": "What the step is: an `action` (send a message, add a tag…), a `delay`, a `condition` or a `wait_for_response`.",
          "title": "Kind"
        },
        "action": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "For an `action`, which one (`add_tag`, `send_text`, `send_template`…); `null` for the other kinds.",
          "title": "Action"
        },
        "status": {
          "type": "string",
          "enum": [
            "completed",
            "failed",
            "skipped",
            "waiting"
          ],
          "description": "`completed`, `failed`, `skipped` (it decided not to act, for example a message that does not apply) or `waiting`. A step can fail and the run still complete, when the automation says to continue after an error.",
          "title": "Status"
        },
        "reason": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "no_conversation",
                "messaging_window_closed",
                "contact_opted_out",
                "template_unavailable",
                "missing_data",
                "automation_disabled",
                "contact_changed",
                "cancelled",
                "could_not_run",
                "step_failed"
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "Why a `failed` step failed, one of the reasons listed in the error of the run; `null` otherwise.",
          "title": "Reason"
        },
        "started_at": {
          "type": "string",
          "description": "When the step started (UTC, ISO 8601).",
          "title": "Started At"
        },
        "ended_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "When the step ended (UTC, ISO 8601), or `null` if it has not.",
          "title": "Ended At"
        }
      },
      "required": [
        "kind",
        "action",
        "status",
        "reason",
        "started_at",
        "ended_at"
      ],
      "description": "One step the automation has run.",
      "title": "AutomationRunStep"
    }
  }
}