{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "$id": "https://raw.githubusercontent.com/api-evangelist/folio/main/json-schema/folio-flow-stage-schema.json",
  "title": "Flow Stage Schema",
  "description": "Flow stage descriptor. A stage can be part of global flow or specific application flow.",
  "x-generated": "2026-10-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/folio-mgr-tenant-entitlements-openapi.yml#/components/schemas/flowStage",
  "id": "flowStage.json",
  "type": "object",
  "properties": {
    "id": {
      "description": "A unique stage identifier",
      "type": "string",
      "format": "uuid"
    },
    "flowId": {
      "description": "A parent flow identifier (global or application flow)",
      "type": "string",
      "format": "uuid"
    },
    "name": {
      "description": "A stage name",
      "type": "string"
    },
    "status": {
      "description": "Stage execution status",
      "$ref": "#/$defs/executionStatus"
    },
    "errorType": {
      "description": "A relevant error type caused stage failure or cancellation, nullable if stage is finished",
      "type": "string"
    },
    "errorMessage": {
      "description": "A relevant error message caused stage failure or cancellation, nullable if stage is finished",
      "type": "string"
    },
    "startedAt": {
      "description": "Stage execution start timestamp",
      "type": "string",
      "format": "date-time"
    },
    "finishedAt": {
      "description": "Stage execution end timestamp",
      "type": "string",
      "format": "date-time"
    },
    "retriesCount": {
      "description": "Number of retries performed during flow stage operations",
      "type": "integer"
    },
    "retriesInfo": {
      "description": "Error information on operations failures that caused retries",
      "type": "string"
    }
  },
  "$defs": {
    "executionStatus": {
      "$schema": "http://json-schema.org/draft-04/schema#",
      "id": "types/entitlementFlowStatus.json",
      "title": "Application/Stage Execution Status Schema",
      "description": "An application/stage execution status",
      "type": "string",
      "enum": [
        "queued",
        "in_progress",
        "cancelled",
        "cancellation_failed",
        "failed",
        "finished"
      ]
    }
  }
}