{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/auditae-app/json-schema/auditae-app-billing-state-schema.json",
  "title": "BillingState",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/auditae-app-billing-api-openapi.yml#/components/schemas/BillingState",
  "type": "object",
  "required": [
    "balance_cents",
    "balance_usd",
    "prices_cents_per_check",
    "estimated_checks_left",
    "auto_refill",
    "billing_url"
  ],
  "properties": {
    "balance_cents": {
      "type": "integer"
    },
    "balance_usd": {
      "type": "string"
    },
    "available_cents": {
      "type": "integer",
      "description": "What a new paid run can use now: the balance less credit held by runs in flight. estimated_checks_left is based on it."
    },
    "prices_cents_per_check": {
      "type": "object",
      "propertyNames": {
        "$ref": "#/$defs/Engine"
      },
      "additionalProperties": {
        "type": "integer"
      }
    },
    "estimated_checks_left": {
      "type": "object",
      "propertyNames": {
        "$ref": "#/$defs/Engine"
      },
      "additionalProperties": {
        "type": "integer"
      }
    },
    "auto_refill": {
      "type": [
        "object",
        "null"
      ],
      "required": [
        "enabled",
        "has_card",
        "amount_cents",
        "threshold_cents",
        "monthly_cap_cents",
        "cap_reached_this_month"
      ],
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "has_card": {
          "type": "boolean"
        },
        "amount_cents": {
          "type": "integer"
        },
        "threshold_cents": {
          "type": "integer"
        },
        "monthly_cap_cents": {
          "type": "integer"
        },
        "cap_reached_this_month": {
          "type": "boolean"
        }
      }
    },
    "billing_url": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "description": "null for an agent workspace (no login): fund it with POST /api/v1/billing/top-up."
    },
    "free_today": {
      "type": "object",
      "description": "Today's (UTC) use of the daily free allowances and what each further call costs. A counter that can't be read is left out; google_data only for a workspace with a login.",
      "properties": {
        "google_data": {
          "$ref": "#/$defs/FreeAllowance"
        },
        "technical_audit": {
          "$ref": "#/$defs/FreeAllowance"
        }
      }
    }
  },
  "$defs": {
    "Engine": {
      "type": "string",
      "enum": [
        "chatgpt",
        "perplexity",
        "gemini",
        "ai-overviews",
        "ai-mode"
      ],
      "description": "Answer engine. ai-mode is opt-in. Check prices: Perplexity 5¢, ChatGPT 7¢, Google AI Overviews 9¢, Google AI Mode 10¢ (opt-in), Gemini 12¢."
    },
    "FreeAllowance": {
      "type": "object",
      "required": [
        "used",
        "of",
        "then_cents"
      ],
      "properties": {
        "used": {
          "type": "integer"
        },
        "of": {
          "type": "integer",
          "description": "Free calls (or pages) a day."
        },
        "then_cents": {
          "type": "integer",
          "description": "Price of each one past the free allowance."
        }
      }
    }
  }
}