{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nopaque-co-uk/json-schema/nopaque-co-uk-workspace-plan-summary-schema.json",
  "title": "WorkspacePlanSummary",
  "description": "The workspace's plan, period, credit and free allowances. Amounts are\nminor units of `currency`, exactly as auth gives them.\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/WorkspacePlanSummary",
  "type": "object",
  "required": [
    "plan",
    "tier",
    "credit",
    "deal",
    "balanceLeft",
    "freePools"
  ],
  "properties": {
    "plan": {
      "type": "string",
      "description": "The plan the workspace is on (auth's effectiveTier)."
    },
    "tier": {
      "type": "string",
      "description": "The stored subscription tier."
    },
    "periodStart": {
      "type": "string",
      "format": "date-time"
    },
    "periodEnd": {
      "type": "string",
      "format": "date-time"
    },
    "credit": {
      "type": [
        "object",
        "null"
      ],
      "description": "Purchased credit left, as the Billing page shows it, or null when\nthe workspace has no billing account yet. Quote `display`.\n",
      "required": [
        "totalCents",
        "currency",
        "display"
      ],
      "properties": {
        "totalCents": {
          "type": "number"
        },
        "currency": {
          "type": "string"
        },
        "display": {
          "type": "string",
          "description": "The amount as the Billing page writes it."
        }
      }
    },
    "deal": {
      "type": [
        "object",
        "null"
      ],
      "description": "A custom deal's summary, or null when there is no deal. Quota\namounts are minor units of `currency`; quote their `display`.\nPer-minute rates are not included.\n",
      "required": [
        "dealRef",
        "state",
        "startsAt",
        "endsAt",
        "endedAt",
        "currency",
        "quota",
        "services"
      ],
      "properties": {
        "dealRef": {
          "type": [
            "string",
            "null"
          ]
        },
        "state": {
          "type": [
            "string",
            "null"
          ],
          "description": "not_started, active or ended."
        },
        "startsAt": {
          "type": [
            "string",
            "null"
          ]
        },
        "endsAt": {
          "type": [
            "string",
            "null"
          ]
        },
        "endedAt": {
          "type": [
            "string",
            "null"
          ]
        },
        "currency": {
          "type": [
            "string",
            "null"
          ]
        },
        "quota": {
          "type": [
            "object",
            "null"
          ],
          "description": "The deal's money quota, or null when it cannot be shown.",
          "required": [
            "granted",
            "used",
            "remaining"
          ],
          "properties": {
            "granted": {
              "$ref": "#/$defs/BillingMoney"
            },
            "used": {
              "$ref": "#/$defs/BillingMoney"
            },
            "remaining": {
              "$ref": "#/$defs/BillingMoney"
            }
          }
        },
        "services": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "service",
              "label",
              "minutesLeft"
            ],
            "properties": {
              "service": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "minutesLeft": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Minutes left at the deal's rate for this service."
              }
            }
          }
        }
      }
    },
    "balanceLeft": {
      "type": "array",
      "description": "What is left to draw usage from, one line per name as the Billing\npage lists it: a plan's licence, a free allocation, a pack. Drained\nlines are left out. Quote `display`.\n",
      "items": {
        "type": "object",
        "required": [
          "name",
          "display"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "display": {
            "type": "string",
            "description": "The amount left as the Billing page writes it."
          }
        }
      }
    },
    "freePools": {
      "type": "array",
      "description": "The Free tier's monthly free allowances. Empty on any other plan,\nwhere they are not counted down.\n",
      "items": {
        "type": "object",
        "required": [
          "key",
          "label",
          "unit",
          "allowance",
          "used"
        ],
        "properties": {
          "key": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "unit": {
            "type": "string",
            "enum": [
              "seconds",
              "tokens"
            ]
          },
          "allowance": {
            "type": "number",
            "minimum": 0
          },
          "used": {
            "type": "number",
            "minimum": 0
          }
        }
      }
    }
  },
  "$defs": {
    "BillingMoney": {
      "type": "object",
      "required": [
        "minor",
        "display"
      ],
      "properties": {
        "minor": {
          "type": "number",
          "description": "Amount in minor units of the deal currency."
        },
        "display": {
          "type": "string",
          "description": "The amount as the Billing page writes it. Quote this."
        }
      }
    }
  }
}