{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/asap-cool/json-schema/asap-cool-subscription-view-schema.json",
  "title": "SubscriptionView",
  "description": "Subscription view returned by `GET /v1/billing/subscription`.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/asap-cool-billing-api-openapi.yml#/components/schemas/SubscriptionView",
  "type": "object",
  "required": [
    "plan",
    "cancel_at_period_end"
  ],
  "properties": {
    "cancel_at_period_end": {
      "type": "boolean",
      "description": "`true` when the user has scheduled an end-of-period cancellation."
    },
    "card": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/$defs/CardView",
          "description": "Card on file, when one has been captured."
        }
      ]
    },
    "current_period_end": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "description": "`current_period_end` as a Unix timestamp (seconds), when known."
    },
    "plan": {
      "type": "string",
      "description": "Resolved plan slug (`starter`, `solo`, `studio`)."
    },
    "status": {
      "type": [
        "string",
        "null"
      ],
      "description": "Stripe subscription status as a lowercase string, when a row exists."
    },
    "trial_end": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "description": "End of the trial as a Unix timestamp (seconds), when in trial: a\nStripe trial, or the 14-day reverse trial every new org starts with\n(`status` is then absent and `plan` is `solo`)."
    }
  },
  "$defs": {
    "CardView": {
      "type": "object",
      "description": "Card on file as exposed by `GET /v1/billing/subscription`.",
      "required": [
        "brand",
        "last4",
        "exp_month",
        "exp_year"
      ],
      "properties": {
        "brand": {
          "type": "string",
          "description": "Card brand (`visa`, `mastercard`, …)."
        },
        "exp_month": {
          "type": "integer",
          "format": "int32",
          "description": "Expiration month (1–12)."
        },
        "exp_year": {
          "type": "integer",
          "format": "int32",
          "description": "Expiration year (four digits)."
        },
        "last4": {
          "type": "string",
          "description": "Last four digits."
        }
      }
    }
  }
}