{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/buildonto-dev/json-schema/buildonto-dev-usage-response-schema.json",
  "title": "UsageResponse",
  "x-generated": "2026-11-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/buildonto-dev-openapi.yaml#/components/schemas/UsageResponse",
  "type": "object",
  "required": [
    "tier",
    "monthly_limit",
    "used_this_month",
    "remaining",
    "overage_allowed",
    "reset_at",
    "concurrent_limit",
    "in_flight",
    "concurrent_remaining",
    "credits"
  ],
  "properties": {
    "tier": {
      "type": "string",
      "enum": [
        "free",
        "starter",
        "growth",
        "scale",
        "enterprise"
      ]
    },
    "monthly_limit": {
      "type": "integer",
      "description": "Plan quota for the current billing month."
    },
    "used_this_month": {
      "type": "integer"
    },
    "remaining": {
      "type": "integer"
    },
    "overage_allowed": {
      "type": "boolean",
      "description": "Whether the tier falls through to credit billing on plan exhaustion."
    },
    "reset_at": {
      "type": "string",
      "format": "date-time",
      "description": "ISO timestamp of next billing-cycle reset (start of next UTC month)."
    },
    "concurrent_limit": {
      "type": "integer"
    },
    "in_flight": {
      "type": "integer"
    },
    "concurrent_remaining": {
      "type": "integer"
    },
    "credits": {
      "type": "object",
      "properties": {
        "balance": {
          "type": "integer",
          "description": "Credits available for overage billing."
        },
        "recent_transactions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CreditTransaction"
          }
        }
      }
    }
  },
  "$defs": {
    "CreditTransaction": {
      "type": "object",
      "required": [
        "id",
        "delta",
        "reason",
        "ref",
        "balance_after",
        "created_at"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "delta": {
          "type": "integer",
          "description": "Positive for credits added, negative for credits used."
        },
        "reason": {
          "type": "string",
          "enum": [
            "purchase",
            "usage",
            "grant",
            "refund",
            "adjustment"
          ]
        },
        "ref": {
          "type": [
            "string",
            "null"
          ],
          "description": "What the entry refers to, such as a payment order ID or a note."
        },
        "balance_after": {
          "type": "integer",
          "description": "Credit balance right after this entry."
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    }
  }
}