{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/run402-com/json-schema/run402-com-metering-block-schema.json",
  "title": "MeteringBlock",
  "description": "prepaid-metered-usage: an organization's metering, on GET /tiers/v1/status and GET /orgs/v1/{org_id}/billing. Every byte count sits beside its human string; every instant is ISO-8601.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/run402-com-billing-api-openapi.yml#/components/schemas/MeteringBlock",
  "type": "object",
  "required": [
    "enabled",
    "cap_usd_micros",
    "suspended_at",
    "suspended_reason",
    "month",
    "month_spent_usd_micros",
    "month_charged_usd_micros",
    "today_estimate_usd_micros",
    "included",
    "headroom",
    "prices",
    "standing_order"
  ],
  "properties": {
    "enabled": {
      "type": "boolean"
    },
    "cap_usd_micros": {
      "type": [
        "integer",
        "null"
      ],
      "description": "One number with two meanings: the most metered usage may cost in a UTC month, and the most the standing order may charge the card in it."
    },
    "suspended_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Set while metering is not charging. Nothing is deleted; the lease's pooled limits apply again."
    },
    "suspended_reason": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "allowance",
        "cap",
        "lease",
        null
      ]
    },
    "month": {
      "type": "object",
      "required": [
        "started_at",
        "ends_at"
      ],
      "properties": {
        "started_at": {
          "type": "string",
          "format": "date-time"
        },
        "ends_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "month_spent_usd_micros": {
      "type": "integer",
      "description": "Σ metered_usage debits this UTC month."
    },
    "month_charged_usd_micros": {
      "type": "integer",
      "description": "Σ standing_order_charge credits this UTC month."
    },
    "today_estimate_usd_micros": {
      "type": "integer",
      "description": "What the next daily pass would charge at the current usage."
    },
    "included": {
      "$ref": "#/$defs/MeteringAmounts"
    },
    "headroom": {
      "$ref": "#/$defs/MeteringAmounts"
    },
    "prices": {
      "type": "object",
      "required": [
        "storage_gb_month_usd_micros",
        "source_gb_month_usd_micros",
        "api_calls_per_million_usd_micros"
      ],
      "properties": {
        "storage_gb_month_usd_micros": {
          "type": "integer"
        },
        "source_gb_month_usd_micros": {
          "type": "integer"
        },
        "api_calls_per_million_usd_micros": {
          "type": "integer"
        }
      }
    },
    "standing_order": {
      "$ref": "#/$defs/StandingOrderBlock"
    }
  },
  "$defs": {
    "MeteringAmounts": {
      "type": "object",
      "description": "The tier's included amounts, or the headroom the cap and the allowance can still pay for over the rest of the UTC month.",
      "required": [
        "storage_bytes",
        "storage",
        "source_bytes",
        "source",
        "api_calls"
      ],
      "properties": {
        "storage_bytes": {
          "type": "integer"
        },
        "storage": {
          "type": "string"
        },
        "source_bytes": {
          "type": "integer"
        },
        "source": {
          "type": "string"
        },
        "api_calls": {
          "type": "integer"
        }
      }
    },
    "StandingOrderBlock": {
      "type": "object",
      "description": "prepaid-metered-usage: the card standing order that refills the allowance under the organization's monthly cap.",
      "required": [
        "enabled",
        "threshold_usd_micros",
        "recharge_usd_micros",
        "disabled_reason",
        "failure_count",
        "payment_method"
      ],
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "threshold_usd_micros": {
          "type": "integer",
          "description": "The card fires when the allowance falls below this."
        },
        "recharge_usd_micros": {
          "type": "integer",
          "description": "What one charge adds, clipped to the cap's remaining room this month."
        },
        "disabled_reason": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "card_failed",
            "card_removed",
            null
          ],
          "description": "`card_failed` after three consecutive declines."
        },
        "failure_count": {
          "type": "integer",
          "description": "Consecutive failed charges; reset by a success."
        },
        "payment_method": {
          "type": [
            "object",
            "null"
          ],
          "description": "The saved card, display fields only, never a Stripe identifier; null until a setup session completes.",
          "required": [
            "brand",
            "last4",
            "exp_month",
            "exp_year"
          ],
          "properties": {
            "brand": {
              "type": "string"
            },
            "last4": {
              "type": "string"
            },
            "exp_month": {
              "type": "integer"
            },
            "exp_year": {
              "type": "integer"
            }
          }
        }
      }
    }
  }
}