{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/telnyx/main/json-schema/telnyx-monthly-charges-summary-response-schema.json",
  "title": "MonthlyChargesSummaryResponse",
  "x-generated": "2026-10-08",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/telnyx-charges-summary-api-openapi.yml#/components/schemas/MonthlyChargesSummaryResponse",
  "properties": {
    "data": {
      "$ref": "#/$defs/SummaryAndTotal"
    }
  },
  "required": [
    "data"
  ],
  "type": "object",
  "$defs": {
    "AdjustmentLine": {
      "properties": {
        "amount": {
          "description": "Adjustment amount as decimal string",
          "type": "string"
        },
        "description": {
          "description": "Description of the adjustment",
          "type": "string"
        },
        "event_date": {
          "description": "Date when the adjustment occurred",
          "format": "date",
          "type": "string"
        }
      },
      "required": [
        "amount",
        "description",
        "event_date"
      ],
      "type": "object"
    },
    "ComparativeLine": {
      "properties": {
        "alias": {
          "description": "Service alias",
          "type": "string"
        },
        "existing_this_month": {
          "$ref": "#/$defs/MonthDetail"
        },
        "name": {
          "description": "Service name",
          "type": "string"
        },
        "new_this_month": {
          "$ref": "#/$defs/MonthDetail"
        },
        "type": {
          "enum": [
            "comparative"
          ],
          "type": "string"
        }
      },
      "required": [
        "type",
        "name",
        "alias",
        "new_this_month",
        "existing_this_month"
      ],
      "type": "object"
    },
    "MonthDetail": {
      "properties": {
        "mrc": {
          "description": "Monthly recurring charge amount as decimal string",
          "type": "string"
        },
        "otc": {
          "description": "One-time charge amount as decimal string",
          "type": [
            "string",
            "null"
          ]
        },
        "quantity": {
          "description": "Number of items",
          "type": "integer"
        }
      },
      "required": [
        "quantity",
        "mrc"
      ],
      "type": "object"
    },
    "SimpleLine": {
      "properties": {
        "alias": {
          "description": "Service alias",
          "type": "string"
        },
        "amount": {
          "description": "Total amount as decimal string",
          "type": "string"
        },
        "name": {
          "description": "Service name",
          "type": "string"
        },
        "quantity": {
          "description": "Number of items",
          "type": "integer"
        },
        "type": {
          "enum": [
            "simple"
          ],
          "type": "string"
        }
      },
      "required": [
        "type",
        "name",
        "alias",
        "quantity",
        "amount"
      ],
      "type": "object"
    },
    "Summary": {
      "properties": {
        "adjustments": {
          "description": "List of billing adjustments",
          "items": {
            "$ref": "#/$defs/AdjustmentLine"
          },
          "type": "array"
        },
        "lines": {
          "description": "List of charge summary lines",
          "items": {
            "$ref": "#/$defs/SummaryLine"
          },
          "type": "array"
        }
      },
      "required": [
        "lines",
        "adjustments"
      ],
      "type": "object"
    },
    "SummaryAndTotal": {
      "properties": {
        "currency": {
          "description": "Currency code",
          "type": "string"
        },
        "end_date": {
          "description": "End date of the summary period",
          "format": "date",
          "type": "string"
        },
        "start_date": {
          "description": "Start date of the summary period",
          "format": "date",
          "type": "string"
        },
        "summary": {
          "$ref": "#/$defs/Summary"
        },
        "total": {
          "$ref": "#/$defs/TotalSummary"
        },
        "user_email": {
          "description": "User email address",
          "format": "email",
          "type": "string"
        },
        "user_id": {
          "description": "User identifier",
          "type": "string"
        }
      },
      "required": [
        "user_id",
        "start_date",
        "end_date",
        "user_email",
        "currency",
        "summary",
        "total"
      ],
      "type": "object"
    },
    "SummaryLine": {
      "oneOf": [
        {
          "$ref": "#/$defs/ComparativeLine"
        },
        {
          "$ref": "#/$defs/SimpleLine"
        }
      ]
    },
    "TotalSummary": {
      "properties": {
        "credits": {
          "description": "Total credits as decimal string",
          "type": "string"
        },
        "existing_mrc": {
          "description": "Total existing monthly recurring charges as decimal string",
          "type": "string"
        },
        "grand_total": {
          "description": "Grand total of all charges as decimal string",
          "type": "string"
        },
        "ledger_adjustments": {
          "description": "Ledger adjustments as decimal string",
          "type": "string"
        },
        "new_mrc": {
          "description": "Total new monthly recurring charges as decimal string",
          "type": "string"
        },
        "new_otc": {
          "description": "Total new one-time charges as decimal string",
          "type": "string"
        },
        "other": {
          "description": "Other charges as decimal string",
          "type": "string"
        }
      },
      "required": [
        "new_mrc",
        "new_otc",
        "existing_mrc",
        "other",
        "credits",
        "ledger_adjustments",
        "grand_total"
      ],
      "type": "object"
    }
  }
}