{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/legivel-com/json-schema/legivel-com-usage-report-schema.json",
  "title": "UsageReport",
  "description": "The account's documents and limits for one usage period.",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/legivel-com-openapi.json#/components/schemas/UsageReport",
  "type": "object",
  "properties": {
    "plan": {
      "type": "string",
      "description": "The id of the plan the period is counted against."
    },
    "period_start": {
      "type": "string",
      "format": "date-time",
      "description": "When the period opened."
    },
    "period_end": {
      "type": "string",
      "format": "date-time",
      "description": "When the period closes."
    },
    "credits_included": {
      "type": "integer",
      "description": "Documents the plan includes in the period."
    },
    "credits_granted": {
      "type": "integer",
      "description": "Documents granted on top of the plan's, such as carry-over on an upgrade."
    },
    "credits_used": {
      "type": "integer",
      "description": "Documents used in the period, editor downloads included; this is the number a 402 reads."
    },
    "limits": {
      "type": "object",
      "title": "UsageLimits",
      "description": "The limits in force for the account in this period, from its plan.",
      "properties": {
        "markdown_kb": {
          "type": "integer",
          "description": "Largest Markdown document, in kibibytes."
        },
        "resources_mb": {
          "type": "number",
          "description": "Total resource bytes one render may load, in mebibytes."
        },
        "pages_max": {
          "type": "integer",
          "description": "Most pages one rendered document may have."
        },
        "timeout_s": {
          "type": "integer",
          "description": "Longest one render may run, in seconds."
        },
        "concurrency": {
          "type": "integer",
          "description": "Renders the account may have in flight at once."
        },
        "requests_per_min": {
          "type": "integer",
          "description": "Requests a minute before the burst limiter refuses."
        },
        "previews_per_hour": {
          "type": "integer",
          "description": "Editor previews an hour; the API never spends these."
        }
      },
      "required": [
        "markdown_kb",
        "resources_mb",
        "pages_max",
        "timeout_s",
        "concurrency",
        "requests_per_min",
        "previews_per_hour"
      ],
      "additionalProperties": false
    },
    "keys": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/KeyUsage"
      },
      "description": "The period's spending split by API key. The editor's share is `credits_used` less the sum of these, so the two need not add up."
    }
  },
  "required": [
    "plan",
    "period_start",
    "period_end",
    "credits_included",
    "credits_granted",
    "credits_used",
    "limits",
    "keys"
  ],
  "additionalProperties": false,
  "$defs": {
    "KeyUsage": {
      "type": "object",
      "title": "KeyUsage",
      "description": "One API key's share of the period.",
      "properties": {
        "id": {
          "type": "string",
          "description": "The API key's id."
        },
        "name": {
          "type": [
            "string",
            "null"
          ],
          "description": "The key's current name; null once the key is gone."
        },
        "credits": {
          "type": "integer",
          "minimum": 0,
          "description": "Documents charged through this key, returned documents excluded."
        }
      },
      "required": [
        "id",
        "name",
        "credits"
      ],
      "additionalProperties": false
    }
  }
}