{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/lexifina/json-schema/lexifina-workflow-run-schema.json",
  "title": "WorkflowRun",
  "description": "A workflow run. Lists omit the per-step detail.",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/lexifina-openapi.json#/components/schemas/WorkflowRun",
  "properties": {
    "id": {
      "title": "Id",
      "type": "string"
    },
    "object": {
      "const": "workflow_run",
      "default": "workflow_run",
      "title": "Object",
      "type": "string"
    },
    "status_detail": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "What the run is doing or waiting for: running, waiting_human, waiting_client, waiting_delay, waiting_budget, completed, failed, partial_failed or cancelled.",
      "title": "Status Detail"
    },
    "flow_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Flow Id"
    },
    "flow_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Flow Name"
    },
    "owner": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Owner"
    },
    "matter_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Matter Id"
    },
    "matter_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Matter Name"
    },
    "client_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Client Name"
    },
    "status": {
      "description": "queued, running, requires_action (an approval or budget decision waits on you), completed, failed or cancelled. status_detail says more.",
      "title": "Status",
      "type": "string"
    },
    "event_type": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Event Type"
    },
    "event_data": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Event Data"
    },
    "trigger_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Trigger Id"
    },
    "trigger_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Trigger Name"
    },
    "graph_version": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Graph Version"
    },
    "start_node_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Start Node Id"
    },
    "node_count": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Node Count"
    },
    "completed_count": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Completed Count"
    },
    "failed_count": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Failed Count"
    },
    "waiting_count": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Waiting Count"
    },
    "duration_ms": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Duration Ms"
    },
    "budget_usd": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Budget Usd"
    },
    "budget": {
      "anyOf": [
        {
          "$ref": "#/$defs/ExecutionBudget"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "node_runs": {
      "anyOf": [
        {
          "additionalProperties": {
            "$ref": "#/$defs/NodeRun"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Each step's latest attempt, by node id.",
      "title": "Node Runs"
    },
    "edge_runs": {
      "anyOf": [
        {
          "additionalProperties": {
            "$ref": "#/$defs/EdgeRun"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Edge Runs"
    },
    "cancel_reason": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Cancel Reason"
    },
    "token_usage": {
      "anyOf": [
        {
          "$ref": "#/$defs/ExecutionTokenUsage"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "node_token_usage": {
      "anyOf": [
        {
          "additionalProperties": {
            "$ref": "#/$defs/ExecutionTokenUsage"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Node Token Usage"
    },
    "created_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Created At"
    },
    "updated_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Updated At"
    },
    "completed_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Completed At"
    }
  },
  "required": [
    "id",
    "object",
    "status_detail",
    "flow_id",
    "flow_name",
    "owner",
    "matter_id",
    "matter_name",
    "client_name",
    "status",
    "event_type",
    "event_data",
    "trigger_id",
    "trigger_name",
    "graph_version",
    "start_node_id",
    "node_count",
    "completed_count",
    "failed_count",
    "waiting_count",
    "duration_ms",
    "budget_usd",
    "budget",
    "node_runs",
    "edge_runs",
    "cancel_reason",
    "token_usage",
    "node_token_usage",
    "created_at",
    "updated_at",
    "completed_at"
  ],
  "type": "object",
  "$defs": {
    "EdgeRun": {
      "properties": {
        "edge_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Edge Id"
        },
        "source": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Source"
        },
        "target": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Target"
        },
        "passed": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Passed"
        },
        "status": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Status"
        },
        "connection_type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Connection Type"
        },
        "evaluated_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Evaluated At"
        }
      },
      "title": "EdgeRun",
      "type": "object",
      "required": [
        "edge_id",
        "source",
        "target",
        "passed",
        "status",
        "connection_type",
        "evaluated_at"
      ]
    },
    "ExecutionBudget": {
      "properties": {
        "limit_usd": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Limit Usd"
        },
        "spent_usd": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Spent Usd"
        },
        "reserved_usd": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Reserved Usd"
        },
        "remaining_usd": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Remaining Usd"
        },
        "agent_step_max_usd": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Agent Step Max Usd"
        },
        "paused": {
          "default": [],
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "title": "Paused",
          "type": "array"
        },
        "changes": {
          "default": [],
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "title": "Changes",
          "type": "array"
        }
      },
      "title": "ExecutionBudget",
      "type": "object",
      "required": [
        "limit_usd",
        "spent_usd",
        "reserved_usd",
        "remaining_usd",
        "agent_step_max_usd",
        "paused",
        "changes"
      ]
    },
    "ExecutionTokenUsage": {
      "properties": {
        "event_count": {
          "default": 0,
          "title": "Event Count",
          "type": "integer"
        },
        "total_tokens": {
          "default": 0,
          "title": "Total Tokens",
          "type": "integer"
        },
        "prompt_tokens": {
          "default": 0,
          "title": "Prompt Tokens",
          "type": "integer"
        },
        "completion_tokens": {
          "default": 0,
          "title": "Completion Tokens",
          "type": "integer"
        },
        "cache_read_input_tokens": {
          "default": 0,
          "title": "Cache Read Input Tokens",
          "type": "integer"
        },
        "cache_creation_input_tokens": {
          "default": 0,
          "title": "Cache Creation Input Tokens",
          "type": "integer"
        },
        "reasoning_output_tokens": {
          "default": 0,
          "title": "Reasoning Output Tokens",
          "type": "integer"
        },
        "tool_use_count": {
          "default": 0,
          "title": "Tool Use Count",
          "type": "integer"
        },
        "total_cost_usd": {
          "default": 0.0,
          "title": "Total Cost Usd",
          "type": "number"
        },
        "models": {
          "default": [],
          "items": {
            "type": "string"
          },
          "title": "Models",
          "type": "array"
        }
      },
      "title": "ExecutionTokenUsage",
      "type": "object",
      "required": [
        "event_count",
        "total_tokens",
        "prompt_tokens",
        "completion_tokens",
        "cache_read_input_tokens",
        "cache_creation_input_tokens",
        "reasoning_output_tokens",
        "tool_use_count",
        "total_cost_usd",
        "models"
      ]
    },
    "NodeRun": {
      "properties": {
        "status": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Status"
        },
        "kind": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Kind"
        },
        "label": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Label"
        },
        "attempt_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Attempt Id"
        },
        "attempt_number": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Attempt Number"
        },
        "output": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Output"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        },
        "started_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Started At"
        },
        "completed_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Completed At"
        }
      },
      "title": "NodeRun",
      "type": "object",
      "required": [
        "status",
        "kind",
        "label",
        "attempt_id",
        "attempt_number",
        "output",
        "error",
        "started_at",
        "completed_at"
      ]
    }
  }
}