{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/bellatorsi-com/json-schema/bellatorsi-com-usage-key-detail-response-schema.json",
  "title": "UsageKeyDetailResponse",
  "description": "Detailed usage for a specific API key in the current month.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/bellatorsi-com-usage-quota-api-openapi.yml#/components/schemas/UsageKeyDetailResponse",
  "properties": {
    "key_id": {
      "type": "string",
      "title": "Key Id",
      "description": "API key UUID"
    },
    "key_prefix": {
      "type": "string",
      "title": "Key Prefix",
      "description": "Visible key prefix"
    },
    "period": {
      "$ref": "#/$defs/UsagePeriod",
      "description": "Current billing period"
    },
    "totals": {
      "additionalProperties": {
        "type": "integer"
      },
      "type": "object",
      "title": "Totals",
      "description": "Aggregated totals for the key"
    },
    "endpoint_breakdown": {
      "items": {
        "$ref": "#/$defs/KeyEndpointUsage"
      },
      "type": "array",
      "title": "Endpoint Breakdown"
    },
    "hourly": {
      "items": {
        "$ref": "#/$defs/KeyHourlyUsage"
      },
      "type": "array",
      "title": "Hourly"
    }
  },
  "type": "object",
  "required": [
    "key_id",
    "key_prefix",
    "period",
    "totals"
  ],
  "$defs": {
    "KeyEndpointUsage": {
      "properties": {
        "endpoint": {
          "type": "string",
          "title": "Endpoint",
          "description": "Endpoint path"
        },
        "calls": {
          "type": "integer",
          "minimum": 0.0,
          "title": "Calls",
          "description": "Calls for this endpoint"
        },
        "tasks": {
          "type": "integer",
          "minimum": 0.0,
          "title": "Tasks",
          "description": "Tasks processed for this endpoint"
        },
        "errors": {
          "type": "integer",
          "minimum": 0.0,
          "title": "Errors",
          "description": "Error responses for this endpoint"
        },
        "avg_response_ms": {
          "type": "number",
          "minimum": 0.0,
          "title": "Avg Response Ms",
          "description": "Average response time in ms"
        }
      },
      "type": "object",
      "required": [
        "endpoint",
        "calls",
        "tasks",
        "errors",
        "avg_response_ms"
      ],
      "title": "KeyEndpointUsage",
      "description": "Per-endpoint usage totals for a single key."
    },
    "KeyHourlyUsage": {
      "properties": {
        "hour": {
          "type": "string",
          "format": "date-time",
          "title": "Hour",
          "description": "UTC hour bucket"
        },
        "calls": {
          "type": "integer",
          "minimum": 0.0,
          "title": "Calls"
        },
        "tasks": {
          "type": "integer",
          "minimum": 0.0,
          "title": "Tasks"
        },
        "errors": {
          "type": "integer",
          "minimum": 0.0,
          "title": "Errors"
        }
      },
      "type": "object",
      "required": [
        "hour",
        "calls",
        "tasks",
        "errors"
      ],
      "title": "KeyHourlyUsage",
      "description": "Hourly usage point for trend charts."
    },
    "UsagePeriod": {
      "properties": {
        "start": {
          "type": "string",
          "format": "date-time",
          "title": "Start",
          "description": "Period start (UTC)"
        },
        "end": {
          "type": "string",
          "format": "date-time",
          "title": "End",
          "description": "Period end (UTC)"
        }
      },
      "type": "object",
      "required": [
        "start",
        "end"
      ],
      "title": "UsagePeriod",
      "description": "Billing period window (UTC month boundaries)."
    }
  }
}