{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nopaque-co-uk/json-schema/nopaque-co-uk-billing-info-schema.json",
  "title": "BillingInfo",
  "description": "Workspace billing snapshot returned by `GET /workspaces/{workspaceId}/billing`.\nCombines subscription state, free-tier pools, purchased capacity, current-period\nusage, and (when available) estimated cost.\n\nFree-minute pools include legacy types (`testing`, `loadTesting`, `mapping`)\nplus the AVE-family `s2s` (Mapping AVE) and `s2stest` (Testing AVE) pools.\nTokens are tracked separately under `freeTokens` and `purchasedTokens`.\n",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nopaque-co-uk-billing-api-openapi.yml#/components/schemas/BillingInfo",
  "type": "object",
  "required": [
    "subscriptionTier",
    "subscriptionStatus",
    "freeMinutes",
    "freeTokens",
    "purchasedMinutes",
    "purchasedTokens",
    "usage"
  ],
  "properties": {
    "subscriptionTier": {
      "type": "string",
      "enum": [
        "free",
        "starter",
        "team",
        "enterprise"
      ]
    },
    "subscriptionStatus": {
      "type": "string",
      "enum": [
        "active",
        "past_due",
        "canceled",
        "trialing",
        "none"
      ]
    },
    "subscriptionId": {
      "type": [
        "string",
        "null"
      ]
    },
    "stripeCustomerId": {
      "type": [
        "string",
        "null"
      ]
    },
    "currentPeriodStart": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "currentPeriodEnd": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "freeMinutes": {
      "type": "object",
      "description": "Free-minute pools per usage type. The `resetDate` indicates the next\nmonthly reset. Values are SECONDS, not minutes (legacy field naming).\n",
      "properties": {
        "testing": {
          "$ref": "#/$defs/FreeMinutesPoolEntry"
        },
        "loadTesting": {
          "$ref": "#/$defs/FreeMinutesPoolEntry"
        },
        "mapping": {
          "$ref": "#/$defs/FreeMinutesPoolEntry"
        },
        "s2s": {
          "$ref": "#/$defs/FreeMinutesPoolEntry"
        },
        "s2stest": {
          "$ref": "#/$defs/FreeMinutesPoolEntry"
        },
        "resetDate": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      }
    },
    "freeTokens": {
      "type": "object",
      "required": [
        "used",
        "limit",
        "remaining"
      ],
      "properties": {
        "used": {
          "type": "integer"
        },
        "limit": {
          "type": "integer"
        },
        "remaining": {
          "type": "integer"
        },
        "resetDate": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      }
    },
    "purchasedMinutes": {
      "type": "object",
      "description": "Remaining seconds in each purchased capacity pool (never expires).",
      "properties": {
        "testing": {
          "type": "integer"
        },
        "loadTesting": {
          "type": "integer"
        },
        "mapping": {
          "type": "integer"
        },
        "s2s": {
          "type": "integer"
        },
        "s2stest": {
          "type": "integer"
        }
      }
    },
    "purchasedTokens": {
      "type": "object",
      "required": [
        "remainingTokens"
      ],
      "properties": {
        "remainingTokens": {
          "type": "integer"
        }
      }
    },
    "usage": {
      "type": "object",
      "description": "Current-period usage stats. `totalSeconds` aggregates ALL types.",
      "required": [
        "totalSeconds",
        "totalMinutes",
        "byType",
        "callCount"
      ],
      "properties": {
        "totalSeconds": {
          "type": "integer"
        },
        "totalMinutes": {
          "type": "number"
        },
        "byType": {
          "type": "object",
          "properties": {
            "mapping": {
              "type": "integer"
            },
            "testing": {
              "type": "integer"
            },
            "loadTesting": {
              "type": "integer"
            },
            "s2s": {
              "type": "integer"
            },
            "s2stest": {
              "type": "integer"
            }
          }
        },
        "byStack": {
          "type": "object",
          "description": "Per-tool-stack usage breakdown. Free-form object keyed by stack identifier.",
          "additionalProperties": true
        },
        "callCount": {
          "type": "integer"
        }
      }
    },
    "estimatedCost": {
      "type": [
        "number",
        "null"
      ],
      "description": "Estimated cost for the current period's PAYG portion. Returns `null` when the\nusage-events GSI is not yet available (early in workspace lifetime).\n"
    }
  },
  "$defs": {
    "FreeMinutesPoolEntry": {
      "type": "object",
      "description": "Free-minute pool for a specific usage type. `used`/`limit`/`remaining` are\nall in seconds (the API converts from backend `usedSecs`/`limitSecs` for\nfrontend ergonomics — historical naming).\n",
      "required": [
        "used",
        "limit",
        "remaining"
      ],
      "properties": {
        "used": {
          "type": "integer",
          "description": "Seconds consumed this period."
        },
        "limit": {
          "type": "integer",
          "description": "Seconds allocated this period (0 for tiers without a free pool)."
        },
        "remaining": {
          "type": "integer",
          "description": "Seconds remaining (can be negative if overage was allowed)."
        }
      }
    }
  }
}