{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/flowra-dev/json-schema/flowra-dev-workflow-statistics-dto-success-response-schema.json",
  "title": "WorkflowStatisticsDtoSuccessResponse",
  "x-generated": "2026-11-08",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/flowra-dev-openapi.json#/components/schemas/WorkflowStatisticsDtoSuccessResponse",
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean",
      "description": "Success status"
    },
    "message": {
      "type": "string",
      "description": "Success message"
    },
    "data": {
      "type": "object",
      "properties": {
        "workflow": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "workflowType": {
              "type": "string",
              "enum": [
                "static",
                "agent"
              ]
            },
            "isActive": {
              "type": "boolean"
            },
            "lastExecutedAt": {
              "type": [
                "string",
                "null"
              ]
            },
            "lastProductionError": {
              "type": "object",
              "properties": {
                "timestamp": {
                  "type": "string"
                },
                "errors": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                }
              },
              "required": [
                "timestamp",
                "errors"
              ]
            }
          },
          "required": [
            "id",
            "name",
            "workflowType",
            "isActive"
          ]
        },
        "health": {
          "type": "object",
          "properties": {
            "total": {
              "type": "number"
            },
            "completed": {
              "type": "number"
            },
            "failed": {
              "type": "number"
            },
            "timeout": {
              "type": "number"
            },
            "paused": {
              "type": "number"
            },
            "running": {
              "type": "number"
            },
            "successRate": {
              "type": [
                "number",
                "null"
              ]
            },
            "durationMinMs": {
              "type": [
                "number",
                "null"
              ]
            },
            "durationAvgMs": {
              "type": [
                "number",
                "null"
              ]
            },
            "durationMaxMs": {
              "type": [
                "number",
                "null"
              ]
            },
            "byMode": {
              "type": "object",
              "properties": {
                "test": {
                  "type": "number"
                },
                "production": {
                  "type": "number"
                }
              }
            }
          },
          "required": [
            "total",
            "completed",
            "failed",
            "timeout",
            "paused",
            "running",
            "successRate",
            "durationMinMs",
            "durationAvgMs",
            "durationMaxMs",
            "byMode"
          ]
        },
        "credits": {
          "type": "object",
          "properties": {
            "totalCredits": {
              "type": "number"
            },
            "totalUsd": {
              "type": [
                "number",
                "null"
              ]
            },
            "byType": {
              "type": "object",
              "properties": {
                "ai_model": {
                  "type": "number"
                },
                "tool": {
                  "type": "number"
                },
                "sandbox": {
                  "type": "number"
                },
                "browser": {
                  "type": "number"
                },
                "workflow": {
                  "type": "number"
                },
                "media": {
                  "type": "number"
                },
                "connected_account": {
                  "type": "number"
                }
              }
            },
            "minCreditsPerRun": {
              "type": [
                "number",
                "null"
              ]
            },
            "maxCreditsPerRun": {
              "type": [
                "number",
                "null"
              ]
            },
            "avgCreditsPerRun": {
              "type": [
                "number",
                "null"
              ]
            },
            "attributedRunCount": {
              "type": "number"
            },
            "unattributedCreditRows": {
              "type": "number"
            }
          },
          "required": [
            "totalCredits",
            "totalUsd",
            "byType",
            "minCreditsPerRun",
            "maxCreditsPerRun",
            "avgCreditsPerRun",
            "attributedRunCount",
            "unattributedCreditRows"
          ]
        },
        "tools": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "toolSlug": {
                "type": "string"
              },
              "calls": {
                "type": "number"
              },
              "successful": {
                "type": "number"
              },
              "failed": {
                "type": "number"
              },
              "credits": {
                "type": "number"
              },
              "usdCost": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "toolSlug",
              "calls",
              "successful",
              "failed",
              "credits",
              "usdCost"
            ]
          }
        },
        "models": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "modelId": {
                "type": "string"
              },
              "calls": {
                "type": "number"
              },
              "credits": {
                "type": "number"
              },
              "totalTokens": {
                "type": "number"
              }
            },
            "required": [
              "modelId",
              "calls",
              "credits",
              "totalTokens"
            ]
          }
        },
        "triggers": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "toolSlug": {
                "type": "string"
              },
              "status": {
                "type": "string"
              },
              "isDisabled": {
                "type": "boolean"
              },
              "statusReason": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "updatedAt": {
                "type": "string"
              },
              "invocationCount": {
                "type": "number"
              },
              "invocationErrors": {
                "type": "number"
              }
            },
            "required": [
              "id",
              "toolSlug",
              "status",
              "isDisabled",
              "updatedAt",
              "invocationCount",
              "invocationErrors"
            ]
          }
        },
        "recentExecutions": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "status": {
                "type": "string"
              },
              "executionMode": {
                "type": "string"
              },
              "startedAt": {
                "type": "string"
              },
              "completedAt": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "executionDurationMs": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "credits": {
                "type": "number"
              }
            },
            "required": [
              "id",
              "status",
              "executionMode",
              "startedAt",
              "credits"
            ]
          }
        },
        "recentCreditLogs": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "creditAmount": {
                "type": "number"
              },
              "delta": {
                "type": "number",
                "description": "Signed wallet change: negative when taken, positive when returned"
              },
              "entryType": {
                "type": "string",
                "enum": [
                  "debit",
                  "credit"
                ]
              },
              "usdCost": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "executionId": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "metadata": {
                "type": [
                  "object",
                  "null"
                ]
              },
              "createdAt": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "type",
              "creditAmount",
              "delta",
              "entryType",
              "usdCost",
              "createdAt"
            ]
          }
        },
        "recentToolLogs": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "toolSlug": {
                "type": "string"
              },
              "successful": {
                "type": "boolean"
              },
              "error": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "executionDurationMs": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "executedAt": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "toolSlug",
              "successful",
              "executedAt"
            ]
          }
        },
        "from": {
          "type": "string"
        },
        "to": {
          "type": "string"
        }
      },
      "required": [
        "workflow",
        "health",
        "credits",
        "tools",
        "models",
        "triggers",
        "recentExecutions",
        "recentCreditLogs",
        "recentToolLogs"
      ]
    }
  },
  "required": [
    "success",
    "message",
    "data"
  ]
}