{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/onclarity-com/json-schema/onclarity-com-budget-response-schema.json",
  "title": "BudgetResponse",
  "description": "A budget plus its computed current-period figures. Periods are UTC calendar-aligned\n(``day`` / ISO ``week`` from Monday / ``month``) or the budget's own ``custom`` window;\n``surfaces``/``lens`` ``None`` = all. ``spent_usd`` is ``None`` while a custom window is\nstill upcoming; ``crossed`` is set once the current period has alerted.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/onclarity-com-agent-costs-api-openapi.yml#/components/schemas/BudgetResponse",
  "properties": {
    "id": {
      "type": "integer",
      "title": "Id"
    },
    "name": {
      "type": "string",
      "title": "Name"
    },
    "enabled": {
      "type": "boolean",
      "title": "Enabled"
    },
    "scope": {
      "type": "string",
      "title": "Scope"
    },
    "project_id": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Project Id"
    },
    "project_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Project Name"
    },
    "period": {
      "type": "string",
      "title": "Period"
    },
    "custom_from": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Custom From"
    },
    "custom_to": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Custom To"
    },
    "surfaces": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Surfaces"
    },
    "lens": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Lens"
    },
    "usd_threshold": {
      "type": "number",
      "title": "Usd Threshold"
    },
    "period_start": {
      "type": "string",
      "format": "date-time",
      "title": "Period Start"
    },
    "period_end": {
      "type": "string",
      "format": "date-time",
      "title": "Period End"
    },
    "state": {
      "type": "string",
      "title": "State"
    },
    "spent_usd": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Spent Usd"
    },
    "crossed": {
      "anyOf": [
        {
          "$ref": "#/$defs/BudgetCrossingResponse"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "type": "object",
  "required": [
    "id",
    "name",
    "enabled",
    "scope",
    "project_id",
    "period",
    "usd_threshold",
    "period_start",
    "period_end",
    "state"
  ],
  "$defs": {
    "BudgetCrossingResponse": {
      "properties": {
        "notified_at": {
          "type": "string",
          "format": "date-time",
          "title": "Notified At"
        },
        "notified_usd": {
          "type": "number",
          "title": "Notified Usd"
        },
        "threshold_at_notify": {
          "type": "number",
          "title": "Threshold At Notify"
        }
      },
      "type": "object",
      "required": [
        "notified_at",
        "notified_usd",
        "threshold_at_notify"
      ],
      "title": "BudgetCrossingResponse",
      "description": "The persisted crossing for the budget's CURRENT period (absent = not crossed)."
    }
  }
}