{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/oxfordledge-com/json-schema/oxfordledge-com-agent-plan-status-response-schema.json",
  "title": "AgentPlanStatusResponse",
  "description": "`GET /api/billing/agent-plan` -- the caller's active Developer plan (or\npay-as-you-go), this month's usage against it, and the sellable plans.\n\nRequired fields are what the API-keys panel dereferences without a\nnull-check: `used_calls`, `hard_stopped`, `month`, `plans`. `plan` and its\nsiblings are null on pay-as-you-go by design (honest-absent, not 0).",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/oxfordledge-com-api-openapi.yml#/components/schemas/AgentPlanStatusResponse",
  "properties": {
    "plan": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Plan",
      "description": "Active AGENT_API_PLANS key, or null = pay-as-you-go."
    },
    "plan_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Plan Name",
      "description": "Display name of the active plan, or null."
    },
    "price_mo": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Price Mo",
      "description": "USD/month of the active plan, or null."
    },
    "included_calls": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Included Calls",
      "description": "Monthly allowance of the active plan, or null."
    },
    "used_calls": {
      "type": "integer",
      "title": "Used Calls",
      "description": "Class-A calls metered this calendar month (UTC)."
    },
    "remaining_calls": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Remaining Calls",
      "description": "included - used, floored at 0; null on pay-as-you-go."
    },
    "hard_stopped": {
      "type": "boolean",
      "title": "Hard Stopped",
      "description": "True when the NEXT call is refused (used >= included and no overage rate). 'You are blocked right now', not 'you went over'."
    },
    "month": {
      "type": "string",
      "title": "Month",
      "description": "The usage month, 'YYYY-MM' (UTC)."
    },
    "plans": {
      "items": {
        "$ref": "#/$defs/AgentPlanOption"
      },
      "type": "array",
      "title": "Plans",
      "description": "The sellable plans, in AGENT_API_PLANS order."
    },
    "overage_available": {
      "type": "boolean",
      "title": "Overage Available",
      "description": "The active plan offers extra calls at a rate (false on pay-as-you-go and on a degraded consent read -- never offer an opt-in we cannot verify).",
      "default": false
    },
    "overage_enabled": {
      "type": "boolean",
      "title": "Overage Enabled",
      "description": "A LIVE mcp_tools consent row exists: extra calls are ON.",
      "default": false
    },
    "overage_reconsent_required": {
      "type": "boolean",
      "title": "Overage Reconsent Required",
      "description": "The live consent is at a different rate than the current plan's (a plan change) -- extra calls pause until re-confirmed.",
      "default": false
    },
    "overage_degraded": {
      "type": "boolean",
      "title": "Overage Degraded",
      "description": "The consent / ledger read FAILED; the overage_* fields are unknown, not off. The next over-call is refused (fail-closed).",
      "default": false
    },
    "overage_per_call_usd": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Overage Per Call Usd",
      "description": "The plan's rate (the quote)."
    },
    "overage_agreed_per_call_usd": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Overage Agreed Per Call Usd",
      "description": "The rate on the live consent row -- the one that bills; null when off."
    },
    "overage_cap_usd": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Overage Cap Usd",
      "description": "The agreed monthly limit on the live consent row; null when off."
    },
    "overage_cap_default_usd": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Overage Cap Default Usd",
      "description": "The offered default limit."
    },
    "overage_cap_max_usd": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Overage Cap Max Usd",
      "description": "The highest settable limit."
    },
    "overage_accrued_usd": {
      "type": "number",
      "title": "Overage Accrued Usd",
      "description": "Extra calls accrued this month under the live consent, priced at its agreed rate and clamped at its cap; not yet settled.",
      "default": 0.0
    },
    "overage_settled_usd": {
      "type": "number",
      "title": "Overage Settled Usd",
      "description": "Extra calls already settled this month (settle-on-change ledger).",
      "default": 0.0
    },
    "overage_url": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Overage Url",
      "description": "Where the rate, the cap and the route that sets it are documented."
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Error",
      "description": "Set ONLY on the 503 (billing unavailable) / 500 (lookup failed) branches, where the route answers {error} and nothing else; the API-keys panel reads it before touching `plans` (tools/check_fe_api_key_agreement.py, 2026-09-13)."
    }
  },
  "additionalProperties": true,
  "type": "object",
  "required": [
    "used_calls",
    "hard_stopped",
    "month",
    "plans"
  ],
  "$defs": {
    "AgentPlanOption": {
      "properties": {
        "key": {
          "type": "string",
          "title": "Key",
          "description": "AGENT_API_PLANS key: 'developer' | 'developer_pro'."
        },
        "name": {
          "type": "string",
          "title": "Name",
          "description": "Display name, e.g. 'Developer'."
        },
        "price_mo": {
          "type": "integer",
          "title": "Price Mo",
          "description": "USD per month, flat recurring."
        },
        "included_calls": {
          "type": "integer",
          "title": "Included Calls",
          "description": "Class-A data-read calls included per month."
        },
        "available": {
          "type": "boolean",
          "title": "Available",
          "description": "True iff the plan's Stripe price is configured on this deploy (STRIPE_PRICE_DEVELOPER / _PRO set). False renders a disabled button, never a checkout that 503s."
        },
        "overage_per_call": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Overage Per Call",
          "description": "USD per successful Class-A call past the allowance, ONLY once the holder turns extra calls on (0.002 Developer / 0.001 Developer Pro); null = the plan offers no overage."
        },
        "overage_cap_default_usd": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Overage Cap Default Usd",
          "description": "The monthly extra-call limit offered when extra calls are turned on without naming one (50 / 250)."
        },
        "overage_cap_max_usd": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Overage Cap Max Usd",
          "description": "The highest limit a holder may set (4x the plan price)."
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "key",
        "name",
        "price_mo",
        "included_calls",
        "available"
      ],
      "title": "AgentPlanOption",
      "description": "One sellable Developer plan as the FE renders it -- straight from\nAGENT_API_PLANS, so the price the customer sees is the constant the\ncheckout bills (a stale literal on a pricing surface is a misquote)."
    }
  }
}