{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pipavia-com/json-schema/pipavia-com-credits-balance-response-schema.json",
  "title": "CreditsBalanceResponse",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/router-pipavia-openapi.json#/components/schemas/CreditsBalanceResponse",
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean",
      "const": true
    },
    "key_id": {
      "type": "string"
    },
    "balance": {
      "type": "integer"
    },
    "metering_enabled": {
      "type": "boolean",
      "description": "True once the key has entered the credit lane (first grant)."
    },
    "mode": {
      "type": "string",
      "enum": [
        "test",
        "live"
      ],
      "description": "The credit shelf's configured mode on this deployment."
    },
    "bundles": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CreditsBundle"
      }
    },
    "topup": {
      "$ref": "#/$defs/CreditsTopupSettings"
    }
  },
  "$defs": {
    "CreditsBundle": {
      "type": "object",
      "description": "One bundle on the credit shelf. Credits are sold only in bundles and burned internally (1 credit per routed router.call).",
      "required": [
        "id",
        "label",
        "credits",
        "priceUsd"
      ],
      "properties": {
        "id": {
          "type": "string",
          "enum": [
            "starter",
            "builder",
            "fleet"
          ]
        },
        "label": {
          "type": "string"
        },
        "credits": {
          "type": "integer"
        },
        "priceUsd": {
          "type": "integer",
          "description": "Whole US dollars."
        },
        "price_configured": {
          "type": "boolean",
          "description": "True when this deployment has a Stripe price configured for the bundle and it can be sold."
        }
      }
    },
    "CreditsTopupSettings": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "threshold": {
          "type": "integer",
          "description": "Balance (credits) below which an auto-top-up fires."
        },
        "bundle": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "starter",
            "builder",
            "fleet",
            null
          ]
        },
        "daily_cap": {
          "type": "integer",
          "description": "Max top-up charges (success or failure) per UTC day."
        },
        "has_payment_method": {
          "type": "boolean"
        }
      }
    }
  }
}