{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/paypal/json-schema/paypal-lifetime-usage-schema.json",
  "title": "LifetimeUsage",
  "description": "Represents the lifetime usage metrics for a given subscription.",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/paypal-subscriptions-api-openapi.yml#/components/schemas/LifetimeUsage",
  "type": "object",
  "properties": {
    "external_subscription_id": {
      "type": "string",
      "description": "Unique external identifier of the subscription."
    },
    "external_historical_usage_amount": {
      "allOf": [
        {
          "$ref": "#/$defs/Amount"
        },
        {
          "description": "The total historical usage amount for this subscription, representing usage accumulated prior to the start of invoiced and current usage tracking."
        }
      ]
    },
    "invoiced_usage_amount": {
      "allOf": [
        {
          "$ref": "#/$defs/Amount"
        },
        {
          "description": "The total usage amount, that has been invoiced for this subscription, provided by your own application."
        }
      ]
    },
    "current_usage_amount": {
      "allOf": [
        {
          "$ref": "#/$defs/Amount"
        },
        {
          "description": "The total usage amount, accumulated for the subscription during the current billing period"
        }
      ]
    },
    "from": {
      "allOf": [
        {
          "$ref": "#/$defs/DateTimeWithZone"
        },
        {
          "description": "The start date and time (with timezone) of the tracked lifetime usage for the subscription."
        }
      ]
    },
    "to": {
      "allOf": [
        {
          "$ref": "#/$defs/DateTimeWithZone"
        },
        {
          "description": "The end date and time (with timezone) of the tracked lifetime usage for the subscription."
        }
      ]
    },
    "usage_thresholds": {
      "type": "array",
      "description": "An array of usage thresholds configured in the subscription's plan.",
      "items": {
        "$ref": "#/$defs/UsageThreshold"
      }
    }
  },
  "$defs": {
    "Amount": {
      "allOf": [
        {
          "$ref": "#/$defs/AmountNoCurrency"
        },
        {
          "type": "object",
          "required": [
            "currency_code"
          ],
          "properties": {
            "currency_code": {
              "$ref": "#/$defs/Currency"
            }
          }
        }
      ]
    },
    "AmountNoCurrency": {
      "type": "object",
      "required": [
        "value"
      ],
      "properties": {
        "value": {
          "type": "number",
          "format": "decimal",
          "description": "The amount value in the corresponding currency unit (e.g., two decimals for USD, no decimals for JPY).",
          "minimum": 0,
          "nullable": false,
          "default": 0
        }
      }
    },
    "Currency": {
      "type": "string",
      "description": "Currency code in ISO 4217 format.",
      "minLength": 3,
      "maxLength": 3,
      "pattern": "^[A-Z]{3}$"
    },
    "DateTimeWithZone": {
      "type": "string",
      "format": "date-time",
      "description": "Date and time in ISO 8601 format."
    },
    "UsageThreshold": {
      "type": "object",
      "description": "Represents a usage threshold milestone for a subscription.",
      "properties": {
        "amount": {
          "allOf": [
            {
              "$ref": "#/$defs/Amount"
            },
            {
              "description": "The usage threshold amount"
            }
          ]
        },
        "completion_ratio": {
          "type": "number",
          "format": "double",
          "description": "The ratio (between 0 and 1) representing the proportion of the threshold amount that has been used."
        },
        "reached_at": {
          "allOf": [
            {
              "$ref": "#/$defs/DateTimeWithZone"
            },
            {
              "description": "The date and time (in ISO 8601 format with timezone) when this usage threshold was reached."
            }
          ]
        }
      }
    }
  }
}