{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/flashdata-dev/json-schema/flashdata-dev-api-key-usage-schema.json",
  "title": "ApiKeyUsage",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/flashdata-dev-credits-api-openapi.yml#/components/schemas/ApiKeyUsage",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "scope",
    "unit",
    "from",
    "to",
    "observedAt",
    "totals",
    "bySource",
    "updating",
    "note"
  ],
  "properties": {
    "scope": {
      "type": "string",
      "const": "account_authorized_sources"
    },
    "unit": {
      "type": "string",
      "const": "Credits"
    },
    "from": {
      "type": "string",
      "format": "date-time"
    },
    "to": {
      "type": "string",
      "format": "date-time"
    },
    "observedAt": {
      "type": "string",
      "format": "date-time"
    },
    "totals": {
      "$ref": "#/$defs/UsageCounts"
    },
    "bySource": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "source",
          "requests",
          "completed",
          "failed",
          "credits"
        ],
        "properties": {
          "source": {
            "type": "string"
          },
          "requests": {
            "type": "integer",
            "minimum": 0
          },
          "completed": {
            "type": "integer",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "minimum": 0
          },
          "credits": {
            "type": "number",
            "minimum": 0
          }
        }
      }
    },
    "updating": {
      "type": "boolean"
    },
    "note": {
      "type": "string"
    }
  },
  "$defs": {
    "UsageCounts": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "requests",
        "completed",
        "failed",
        "credits"
      ],
      "properties": {
        "requests": {
          "type": "integer",
          "minimum": 0
        },
        "completed": {
          "type": "integer",
          "minimum": 0
        },
        "failed": {
          "type": "integer",
          "minimum": 0
        },
        "credits": {
          "type": "number",
          "minimum": 0,
          "description": "Charged Credits in the current aggregate; pending work may not be finally settled."
        }
      }
    }
  }
}