{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/publicaml-org/json-schema/publicaml-org-issued-free-key-schema.json",
  "title": "IssuedFreeKey",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/publicaml-org-openapi.json#/components/schemas/IssuedFreeKey",
  "type": "object",
  "required": [
    "api_key",
    "tier",
    "rate_limit_units",
    "window_sec",
    "created_at",
    "reissued"
  ],
  "properties": {
    "api_key": {
      "type": "string",
      "description": "`tg_…`. Send it as `X-API-Key` on every call; it has no secret and cannot sign."
    },
    "key_hint": {
      "type": "string",
      "description": "16-hex fingerprint, safe to log. The same id usage accounting groups by."
    },
    "customer_id": {
      "type": "string",
      "description": "`tg-<telegram_user_id>`."
    },
    "external_id": {
      "type": "string"
    },
    "tier": {
      "type": "string",
      "enum": [
        "free",
        "pro",
        "enterprise"
      ]
    },
    "hmac": {
      "type": "boolean",
      "const": false
    },
    "rate_limit_units": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Units (addresses) this key may spend per `window_sec`, metered per key across every endpoint. null = unmetered."
    },
    "window_sec": {
      "type": "integer",
      "description": "Rate-limit window in seconds (3600 in production)."
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "reissued": {
      "type": "boolean",
      "description": "true when an existing active key was returned instead of a new one."
    },
    "docs": {
      "type": "object",
      "properties": {
        "base_url": {
          "type": "string"
        },
        "console": {
          "type": "string"
        },
        "openapi": {
          "type": "string"
        },
        "rate_limits": {
          "type": "string"
        }
      }
    },
    "usage": {
      "type": [
        "object",
        "null"
      ],
      "description": "How much of its quota this key has spent. `null` when the rate-limit store or the usage log could not be read; the key itself is still returned. The current-window numbers are read from the same counter the rate limiter charges, so they equal the `RateLimit-*` headers the key's own calls receive. Calling this endpoint never charges the user's key.",
      "required": [
        "window_sec",
        "units_limit",
        "units_used",
        "units_remaining",
        "reset_at",
        "used_24h",
        "used_30d",
        "last_used_at"
      ],
      "properties": {
        "window_sec": {
          "type": "integer",
          "description": "Length of the quota window in seconds (3600 in production)."
        },
        "units_limit": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Units per window. null = the key is not metered; then units_used, units_remaining and reset_at are null too."
        },
        "units_used": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Units spent in the current window, rejected (429) requests included, as the limiter counts them."
        },
        "units_remaining": {
          "type": [
            "integer",
            "null"
          ],
          "description": "max(0, units_limit - units_used). Same number as `RateLimit-Remaining`."
        },
        "reset_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "End of the current window, UTC. The window is fixed, not rolling: the whole quota comes back at this instant."
        },
        "used_24h": {
          "type": "integer",
          "description": "Units spent in the last 24 hours, from usage accounting. Trails live traffic by up to ~15 s."
        },
        "used_30d": {
          "type": "integer",
          "description": "Units spent in the last 30 days, from usage accounting."
        },
        "last_used_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Start of the minute (UTC) of the key's most recent request, or null if it was never used."
        }
      }
    }
  }
}