{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/walletlink-social/json-schema/walletlink-social-usage-schema.json",
  "title": "Usage",
  "x-generated": "2026-11-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/walletlink-social-openapi.yaml#/components/schemas/Usage",
  "type": "object",
  "required": [
    "key",
    "credits",
    "plan_limits",
    "rate_limits",
    "usage"
  ],
  "properties": {
    "key": {
      "type": "object",
      "required": [
        "id",
        "name",
        "prefix",
        "plan",
        "created_at"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "prefix": {
          "type": "string",
          "description": "The visible leading characters of the key. The rest is stored only as a hash."
        },
        "plan": {
          "type": "string",
          "description": "The rate-limit preset your requests are currently served\nunder, not the pack you bought. `Developer` by default;\n`Startup` while a Scale pack is unexpired, `Enterprise` while\nan Index pack is.\n"
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "last_used_at": {
          "type": "string",
          "format": "date-time",
          "description": "Omitted if the key has never been used."
        }
      }
    },
    "credits": {
      "type": "object",
      "description": "The match meter: what you bought, and what ends a session with a\n402. This is the number to read before deciding whether the next\ncall will work.\n",
      "required": [
        "available",
        "unmetered",
        "on_free_allowance",
        "free_window_resets_at"
      ],
      "properties": {
        "available": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Matches left. `null` only for an unmetered account, where there\nis no number to report.\n"
        },
        "unmetered": {
          "type": "boolean",
          "description": "Whether this account draws on a balance at all."
        },
        "on_free_allowance": {
          "type": "boolean",
          "description": "Whether the remaining balance is the free 30-day allowance rather than a pack."
        },
        "free_window_resets_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "When the free 30-day window rolls forward, or `null`."
        }
      }
    },
    "plan_limits": {
      "type": "object",
      "description": "The request meter: how hard this key may hit the service. Separate\nfrom `credits`, and not what is sold.\n",
      "required": [
        "requests_per_minute",
        "requests_per_day",
        "requests_per_month",
        "max_batch_size"
      ],
      "properties": {
        "requests_per_minute": {
          "type": "integer"
        },
        "requests_per_day": {
          "oneOf": [
            {
              "type": "integer"
            },
            {
              "type": "string",
              "const": "unlimited"
            }
          ],
          "description": "The string `unlimited` where no daily cap applies."
        },
        "requests_per_month": {
          "oneOf": [
            {
              "type": "integer"
            },
            {
              "type": "string",
              "const": "unlimited"
            }
          ]
        },
        "max_batch_size": {
          "type": "integer",
          "description": "The batch limit this key is actually held to."
        }
      }
    },
    "rate_limits": {
      "type": "object",
      "description": "Live state of the three windows. A window is `null` when this plan\ndoes not cap it.\n",
      "required": [
        "minute",
        "day",
        "month"
      ],
      "properties": {
        "minute": {
          "$ref": "#/$defs/RateLimitWindow"
        },
        "day": {
          "$ref": "#/$defs/RateLimitWindow"
        },
        "month": {
          "$ref": "#/$defs/RateLimitWindow"
        }
      }
    },
    "usage": {
      "type": "object",
      "required": [
        "period",
        "total_requests",
        "total_credits",
        "total_wallets",
        "avg_latency_ms",
        "error_rate",
        "requests_by_endpoint",
        "requests_by_day"
      ],
      "properties": {
        "period": {
          "type": "string",
          "enum": [
            "day",
            "week",
            "month"
          ]
        },
        "total_requests": {
          "type": "integer"
        },
        "total_credits": {
          "type": "integer",
          "description": "Rate-limit units, one per wallet requested. **Not matches.**\nKept under its historical name because integrators read it; the\nmatch balance is `credits` above.\n"
        },
        "total_wallets": {
          "type": "integer"
        },
        "avg_latency_ms": {
          "type": "integer"
        },
        "error_rate": {
          "type": "number",
          "description": "Share of requests that returned 400 or above, as a percentage to two decimal places."
        },
        "requests_by_endpoint": {
          "type": "object",
          "description": "Keyed by route template, never by concrete path, so the map\nstays bounded and records no address you looked up.\n",
          "additionalProperties": {
            "type": "integer"
          }
        },
        "requests_by_day": {
          "type": "array",
          "description": "One entry per calendar day in the period that saw traffic, ascending.",
          "items": {
            "type": "object",
            "required": [
              "date",
              "count",
              "credits"
            ],
            "properties": {
              "date": {
                "type": "string",
                "format": "date"
              },
              "count": {
                "type": "integer"
              },
              "credits": {
                "type": "integer"
              }
            }
          }
        }
      }
    }
  },
  "$defs": {
    "RateLimitWindow": {
      "type": [
        "object",
        "null"
      ],
      "description": "One rate-limit window, or `null` when this plan does not cap it.",
      "required": [
        "limit",
        "remaining",
        "reset_at"
      ],
      "properties": {
        "limit": {
          "type": "integer"
        },
        "remaining": {
          "type": "integer"
        },
        "reset_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    }
  }
}