{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/beatra-ai/json-schema/beatra-ai-billing-overview-response-schema.json",
  "title": "BillingOverviewResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/beatra-ai-account-api-openapi.yml#/components/schemas/BillingOverviewResponse",
  "properties": {
    "balance_credits": {
      "type": "string",
      "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
      "title": "Balance Credits"
    },
    "expiring_credits": {
      "type": "string",
      "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
      "title": "Expiring Credits"
    },
    "non_expiring_credits": {
      "type": "string",
      "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
      "title": "Non Expiring Credits"
    },
    "next_expiry_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Next Expiry At"
    },
    "next_expiry_credits": {
      "type": "string",
      "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
      "title": "Next Expiry Credits",
      "default": "0"
    },
    "active_pass": {
      "anyOf": [
        {
          "$ref": "#/$defs/ActivePassItem"
        },
        {
          "type": "null"
        }
      ]
    },
    "active_subscription": {
      "anyOf": [
        {
          "$ref": "#/$defs/AccountSubscriptionItem"
        },
        {
          "type": "null"
        }
      ]
    },
    "recent_grants": {
      "items": {
        "$ref": "#/$defs/CreditGrantSummaryItem"
      },
      "type": "array",
      "title": "Recent Grants"
    },
    "ledger": {
      "items": {
        "$ref": "#/$defs/LedgerEntry"
      },
      "type": "array",
      "title": "Ledger"
    },
    "starter_usage": {
      "anyOf": [
        {
          "$ref": "#/$defs/StarterUsageItem"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "type": "object",
  "required": [
    "balance_credits",
    "expiring_credits",
    "non_expiring_credits",
    "recent_grants",
    "ledger"
  ],
  "$defs": {
    "AccountSubscriptionItem": {
      "properties": {
        "subscription_id": {
          "type": "string",
          "title": "Subscription Id"
        },
        "status": {
          "type": "string",
          "title": "Status"
        },
        "product_id": {
          "type": "string",
          "title": "Product Id"
        },
        "term_id": {
          "type": "string",
          "title": "Term Id"
        },
        "offer_id": {
          "type": "string",
          "title": "Offer Id"
        },
        "provider": {
          "type": "string",
          "title": "Provider"
        },
        "billing_interval": {
          "type": "string",
          "title": "Billing Interval"
        },
        "current_period_start": {
          "type": "string",
          "format": "date-time",
          "title": "Current Period Start"
        },
        "current_period_end": {
          "type": "string",
          "format": "date-time",
          "title": "Current Period End"
        },
        "cancel_at_period_end": {
          "type": "boolean",
          "title": "Cancel At Period End"
        },
        "canceled_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Canceled At"
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "title": "Created At"
        },
        "updated_at": {
          "type": "string",
          "format": "date-time",
          "title": "Updated At"
        }
      },
      "type": "object",
      "required": [
        "subscription_id",
        "status",
        "product_id",
        "term_id",
        "offer_id",
        "provider",
        "billing_interval",
        "current_period_start",
        "current_period_end",
        "cancel_at_period_end",
        "created_at",
        "updated_at"
      ],
      "title": "AccountSubscriptionItem"
    },
    "ActivePassItem": {
      "properties": {
        "term": {
          "type": "string",
          "title": "Term"
        },
        "plan_level": {
          "type": "string",
          "title": "Plan Level"
        },
        "expires_at": {
          "type": "string",
          "format": "date-time",
          "title": "Expires At"
        },
        "auto_renew": {
          "type": "boolean",
          "title": "Auto Renew"
        }
      },
      "type": "object",
      "required": [
        "term",
        "plan_level",
        "expires_at",
        "auto_renew"
      ],
      "title": "ActivePassItem",
      "description": "The plan pass the account currently holds, if any.\n\nValidity is decided by the clock, not the balance: a customer who has spent\nevery credit still holds the pass they paid for until it lapses. Tying the\nidentity to `remaining_credits > 0` would make spending feel like losing\nsomething, which is exactly the wrong incentive on a prepaid product."
    },
    "CreditGrantSummaryItem": {
      "properties": {
        "grant_id": {
          "type": "string",
          "title": "Grant Id"
        },
        "source_type": {
          "type": "string",
          "title": "Source Type"
        },
        "remaining_credits": {
          "type": "string",
          "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
          "title": "Remaining Credits"
        },
        "expires_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Expires At"
        },
        "status": {
          "type": "string",
          "title": "Status"
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "title": "Created At"
        }
      },
      "type": "object",
      "required": [
        "grant_id",
        "source_type",
        "remaining_credits",
        "status",
        "created_at"
      ],
      "title": "CreditGrantSummaryItem"
    },
    "LedgerEntry": {
      "properties": {
        "ledger_id": {
          "type": "string",
          "title": "Ledger Id"
        },
        "ledger_type": {
          "type": "string",
          "title": "Ledger Type"
        },
        "amount_credits": {
          "type": "string",
          "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
          "title": "Amount Credits"
        },
        "balance_after_credits": {
          "type": "string",
          "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
          "title": "Balance After Credits"
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "title": "Created At"
        },
        "task_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Task Id"
        },
        "capability": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Capability"
        },
        "model": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Model"
        },
        "operation": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "clone",
                "activate"
              ]
            },
            {
              "type": "null"
            }
          ],
          "title": "Operation"
        }
      },
      "type": "object",
      "required": [
        "ledger_id",
        "ledger_type",
        "amount_credits",
        "balance_after_credits",
        "created_at"
      ],
      "title": "LedgerEntry"
    },
    "StarterUsageItem": {
      "properties": {
        "started_at": {
          "type": "string",
          "format": "date-time",
          "title": "Started At"
        },
        "plan_credits": {
          "type": "string",
          "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
          "title": "Plan Credits"
        },
        "used_credits": {
          "type": "string",
          "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
          "title": "Used Credits"
        }
      },
      "type": "object",
      "required": [
        "started_at",
        "plan_credits",
        "used_credits"
      ],
      "title": "StarterUsageItem",
      "description": "How much of this period's Starter plan has been used, and since when."
    }
  }
}