{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pepbank-io/json-schema/pepbank-io-account-usage-schema.json",
  "title": "AccountUsage",
  "description": "The caller's account, plan, grants and usage in the current windows.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pepbank-io-account-api-openapi.yml#/components/schemas/AccountUsage",
  "type": "object",
  "properties": {
    "credit": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string",
          "enum": [
            "Data from PepBank"
          ]
        },
        "line": {
          "type": "string",
          "description": "Credit sentence. Copy it as written."
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "PepBank page for this result. The home page applies when no single page fits."
        },
        "license_url": {
          "type": "string",
          "enum": [
            "https://creativecommons.org/licenses/by/4.0/"
          ]
        }
      },
      "required": [
        "text",
        "url",
        "license_url"
      ]
    },
    "record_type": {
      "type": "string",
      "enum": [
        "account_usage"
      ]
    },
    "account": {
      "type": "object",
      "properties": {
        "account_key": {
          "type": "string"
        },
        "account_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "kind": {
          "type": "string"
        }
      },
      "required": [
        "account_key",
        "account_id",
        "kind"
      ]
    },
    "plan": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "name"
      ]
    },
    "entitlement": {
      "type": "object",
      "properties": {},
      "additionalProperties": {}
    },
    "usage": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "meter": {
            "type": "string"
          },
          "limit": {
            "type": [
              "number",
              "null"
            ]
          },
          "used": {
            "type": [
              "number",
              "null"
            ]
          },
          "remaining": {
            "type": [
              "number",
              "null"
            ]
          },
          "window": {
            "type": "string"
          },
          "window_resets_at": {
            "type": "string"
          }
        },
        "required": [
          "meter",
          "limit",
          "used",
          "remaining",
          "window",
          "window_resets_at"
        ]
      }
    }
  },
  "required": [
    "credit",
    "record_type",
    "account",
    "plan",
    "entitlement",
    "usage"
  ]
}