{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/granite-md/json-schema/granite-md-billing-status-schema.json",
  "title": "BillingStatus",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/granite-md-openapi.yaml#/components/schemas/BillingStatus",
  "type": "object",
  "required": [
    "plan",
    "plan_name",
    "monthly_price_cents",
    "per_seat",
    "status",
    "seats",
    "storage_bytes",
    "storage_limit_bytes",
    "purchasable",
    "manageable"
  ],
  "properties": {
    "plan": {
      "type": "string",
      "description": "free, pro, or business"
    },
    "plan_name": {
      "type": "string"
    },
    "monthly_price_cents": {
      "type": "integer",
      "format": "int64",
      "description": "Per seat for per-seat plans."
    },
    "per_seat": {
      "type": "boolean"
    },
    "status": {
      "type": "string",
      "enum": [
        "free",
        "trial",
        "active",
        "past_due",
        "lapsed"
      ],
      "description": "`trial`: a workspace's free 30 days. `past_due`: a payment failed; the plan works\nuntil `grace_until`. `lapsed`: a workspace whose trial ended without a subscription.\n"
    },
    "trial_ends_at": {
      "type": "string",
      "format": "date-time"
    },
    "grace_until": {
      "type": "string",
      "format": "date-time"
    },
    "seats": {
      "type": "integer",
      "format": "int64"
    },
    "storage_bytes": {
      "type": "integer",
      "format": "int64"
    },
    "storage_limit_bytes": {
      "type": "integer",
      "format": "int64"
    },
    "purchasable": {
      "type": "boolean",
      "description": "Payments are set up on this server."
    },
    "manageable": {
      "type": "boolean",
      "description": "There is a billing account (portal and invoices)."
    },
    "pro_trial_days": {
      "type": "integer",
      "format": "int64",
      "description": "Free days a Pro checkout starts with: 30 for a person who never had Pro or a Pro\ntrial on any channel (web, App Store, Google Play), else 0. Always 0 for a workspace.\n"
    },
    "subscription": {
      "$ref": "#/$defs/SubscriptionSummary"
    },
    "company": {
      "$ref": "#/$defs/Company"
    }
  },
  "$defs": {
    "Company": {
      "type": "object",
      "description": "The workspace a company account belongs to. Its plan is the person's plan; there is\nnothing for the person to buy.\n",
      "required": [
        "workspace_id",
        "workspace_name"
      ],
      "properties": {
        "workspace_id": {
          "type": "string",
          "format": "uuid"
        },
        "workspace_name": {
          "type": "string"
        }
      }
    },
    "SubscriptionSummary": {
      "type": "object",
      "required": [
        "provider",
        "status",
        "seats",
        "cancel_at_period_end"
      ],
      "properties": {
        "provider": {
          "type": "string",
          "enum": [
            "stripe",
            "app_store",
            "google_play",
            "internal"
          ],
          "description": "Where it is paid; `internal` is granted by Granite and never billed."
        },
        "status": {
          "type": "string"
        },
        "seats": {
          "type": "integer",
          "format": "int32"
        },
        "current_period_end": {
          "type": "string",
          "format": "date-time"
        },
        "cancel_at_period_end": {
          "type": "boolean"
        }
      }
    }
  }
}