{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/grepr/json-schema/grepr-billing-summary-response-schema.json",
  "title": "BillingSummaryResponse",
  "description": "Per-period billing summary: contract bounds, period, summary.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/grepr-billing-api-openapi.yml#/components/schemas/BillingSummaryResponse",
  "properties": {
    "contract": {
      "$ref": "#/$defs/Contract"
    },
    "period": {
      "$ref": "#/$defs/PeriodEntry"
    },
    "summary": {
      "$ref": "#/$defs/BillingSummary"
    }
  },
  "required": [
    "contract",
    "period",
    "summary"
  ],
  "type": "object",
  "$defs": {
    "AnnualCreditPoolSummary": {
      "description": "Commitment summary for Annual - Credit Pool plans.",
      "properties": {
        "annualCommitment": {
          "description": "Yearly committed dollar amount.",
          "type": "number"
        },
        "usedCumulative": {
          "description": "Cumulative dollar value of consumption since contract start.",
          "type": "number"
        },
        "usedThisPeriod": {
          "description": "Dollar value of consumption during this reporting period.",
          "type": "number"
        }
      },
      "required": [
        "annualCommitment",
        "usedCumulative",
        "usedThisPeriod"
      ],
      "type": "object"
    },
    "AnnualDataProcessingSummary": {
      "description": "Commitment summary for Annual - Data Processing plans.",
      "properties": {
        "rows": {
          "default": [],
          "description": "One row per metric the customer is pre-committed on (e.g. Data Processing GB, Compute Units).",
          "items": {
            "$ref": "#/$defs/MeteredDimensionCommitment"
          },
          "type": "array"
        }
      },
      "required": [
        "rows"
      ],
      "type": "object"
    },
    "AnnualSaasPreCommitmentSummary": {
      "description": "Pre-commitment summary for Annual + SaaS plans.",
      "properties": {
        "rows": {
          "default": [],
          "description": "One row per metric the customer is pre-committed on, ordered by the configured displayed brick id list.",
          "items": {
            "$ref": "#/$defs/MeteredDimensionCommitment"
          },
          "type": "array"
        }
      },
      "required": [
        "rows"
      ],
      "type": "object"
    },
    "BillingSummary": {
      "description": "Plan-specific usage summary.",
      "oneOf": [
        {
          "$ref": "#/$defs/PaygSummary"
        },
        {
          "$ref": "#/$defs/MonthlyCreditPoolSummary"
        },
        {
          "$ref": "#/$defs/AnnualCreditPoolSummary"
        },
        {
          "$ref": "#/$defs/AnnualDataProcessingSummary"
        },
        {
          "$ref": "#/$defs/AnnualSaasPreCommitmentSummary"
        }
      ],
      "properties": {
        "type": {
          "type": "string"
        }
      },
      "required": [
        "type"
      ],
      "type": "object"
    },
    "Contract": {
      "description": "Metadata about the contract.",
      "properties": {
        "endDate": {
          "description": "Inclusive contract end date — the last day this contract covers. For renewed or recast contracts, this is the day before the next contract's start.",
          "format": "date",
          "type": "string"
        },
        "startDate": {
          "description": "Inclusive contract start date.",
          "format": "date",
          "type": "string"
        }
      },
      "required": [
        "endDate",
        "startDate"
      ],
      "type": "object"
    },
    "MeteredDimensionCommitment": {
      "description": "One metric row in a per-metric pre-commitment summary table.",
      "properties": {
        "annualCommitment": {
          "description": "Annually committed quantity for this metric.",
          "type": "number"
        },
        "metric": {
          "description": "Metric name (e.g. \"Data Processing GB\", \"Compute Units\").",
          "type": "string"
        },
        "usedCumulative": {
          "description": "Quantity consumed cumulatively since the contract started.",
          "type": "number"
        },
        "usedThisPeriod": {
          "description": "Quantity consumed during the reporting period.",
          "type": "number"
        }
      },
      "required": [
        "annualCommitment",
        "metric",
        "usedCumulative",
        "usedThisPeriod"
      ],
      "type": "object"
    },
    "MonthlyCreditPoolSummary": {
      "description": "Commitment summary for Monthly + Credit Pool plans.",
      "properties": {
        "credits": {
          "description": "Monthly recurring committed dollar amount.",
          "type": "number"
        },
        "total": {
          "description": "Gross consumption in dollars for this reporting period.",
          "type": "number"
        }
      },
      "required": [
        "credits",
        "total"
      ],
      "type": "object"
    },
    "PaygSummary": {
      "description": "Commitment summary for Monthly + PAYG plans.",
      "properties": {
        "chargedThisPeriod": {
          "description": "Invoice total for this reporting period.",
          "type": "number"
        }
      },
      "type": "object"
    },
    "PeriodEntry": {
      "description": "One reporting period — dropdown entry plus bounds for display.",
      "properties": {
        "current": {
          "description": "True if this entry's period contains today.",
          "type": "boolean"
        },
        "endDate": {
          "description": "Inclusive period end date — the last day in the period.",
          "format": "date",
          "type": "string"
        },
        "id": {
          "description": "Canonical period identifier used in the URL — \"YYYY-MM-DD\" (the period's start date) for both monthly and annual plans.",
          "type": "string"
        },
        "startDate": {
          "description": "Inclusive period start date.",
          "format": "date",
          "type": "string"
        }
      },
      "required": [
        "endDate",
        "id",
        "startDate"
      ],
      "type": "object"
    }
  }
}