{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/popnow-ai/json-schema/popnow-ai-saved-usdrun-schema.json",
  "title": "SavedUSDRun",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/popnow-ai-openapi.yml#/components/schemas/SavedUSDRun",
  "type": "object",
  "required": [
    "currency",
    "cost_usd",
    "available_usd",
    "spent_usd",
    "needs_confirmation"
  ],
  "properties": {
    "currency": {
      "type": "string",
      "const": "USD"
    },
    "cost_usd": {
      "type": "string",
      "pattern": "^[0-9]+(\\.[0-9]{1,9})?$",
      "description": "Quoted steps total, incomplete when unpriced_steps is present. Resume quotes include committed amounts plus remaining steps. Status reads report current step estimates."
    },
    "available_usd": {
      "type": "string",
      "pattern": "^-?[0-9]+(\\.[0-9]{1,9})?$",
      "description": "Independent API wallet available balance."
    },
    "spent_usd": {
      "type": "string",
      "pattern": "^-?[0-9]+(\\.[0-9]{1,9})?$",
      "description": "Net actual charge from the original API payer ledger on status reads; zero in quote/start responses."
    },
    "max_usd": {
      "type": "string",
      "pattern": "^[0-9]+(\\.[0-9]{1,9})?$",
      "description": "Approved total budget, when present."
    },
    "quote_id": {
      "type": "string",
      "description": "Fingerprint binding steps, inputs, prices and original identity."
    },
    "needs_confirmation": {
      "type": "boolean"
    },
    "unpriced_steps": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Step IDs not yet priceable because required dependency outputs are missing. These steps cannot run; zero is not a free price."
    },
    "run_id": {
      "type": "string"
    },
    "state": {
      "type": "string",
      "enum": [
        "draft",
        "running",
        "paused",
        "done",
        "stopped",
        "failed"
      ]
    },
    "pause_reason": {
      "type": "string"
    },
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "stepId",
          "state"
        ],
        "properties": {
          "stepId": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "jobId": {
            "type": "string"
          },
          "uri": {
            "type": "string"
          }
        }
      }
    }
  }
}