{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/clusterhack-dev/json-schema/clusterhack-dev-subscription-schema.json",
  "title": "Subscription",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/clusterhack-dev-billing-api-openapi.yml#/components/schemas/Subscription",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "readOnly": true
    },
    "plan": {
      "allOf": [
        {
          "$ref": "#/$defs/Plan"
        }
      ],
      "readOnly": true
    },
    "status": {
      "$ref": "#/$defs/SubscriptionStatusEnum"
    },
    "is_entitled": {
      "type": "boolean",
      "readOnly": true
    },
    "current_period_end": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "created": {
      "type": "string",
      "format": "date-time",
      "readOnly": true
    },
    "updated": {
      "type": "string",
      "format": "date-time",
      "readOnly": true
    }
  },
  "required": [
    "created",
    "id",
    "is_entitled",
    "plan",
    "updated"
  ],
  "$defs": {
    "Plan": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer",
          "readOnly": true
        },
        "code": {
          "type": "string",
          "title": "Plan code",
          "description": "Stable machine identifier, e.g. 'free', 'pro', 'corp'.",
          "maxLength": 32,
          "pattern": "^[-a-zA-Z0-9_]+$"
        },
        "name": {
          "type": "string",
          "title": "Display name",
          "maxLength": 120
        },
        "price_cents": {
          "type": "integer",
          "maximum": 2147483647,
          "minimum": 0,
          "title": "Monthly price, cents",
          "description": "0 = free tier."
        },
        "currency": {
          "type": "string",
          "maxLength": 3
        },
        "allow_branding": {
          "type": "boolean",
          "title": "White-label branding"
        },
        "allow_private_events": {
          "type": "boolean",
          "title": "Private events"
        },
        "allow_analytics": {
          "type": "boolean",
          "title": "Analytics dashboard"
        },
        "max_events": {
          "type": [
            "integer",
            "null"
          ],
          "maximum": 2147483647,
          "minimum": 0,
          "description": "Maximum number of events the organizer may own. NULL = unlimited."
        },
        "max_participants_per_event": {
          "type": [
            "integer",
            "null"
          ],
          "maximum": 2147483647,
          "minimum": 0,
          "description": "Maximum participants per event. NULL = unlimited."
        },
        "is_default": {
          "type": "boolean",
          "title": "Default plan",
          "description": "Assigned to new organizers automatically."
        },
        "sort_order": {
          "type": "integer",
          "maximum": 32767,
          "minimum": 0
        }
      },
      "required": [
        "code",
        "id",
        "name"
      ]
    },
    "SubscriptionStatusEnum": {
      "enum": [
        "active",
        "trialing",
        "past_due",
        "canceled",
        "incomplete"
      ],
      "type": "string",
      "description": "* `active` - Active\n* `trialing` - Trialing\n* `past_due` - Past due\n* `canceled` - Canceled\n* `incomplete` - Incomplete"
    }
  }
}