{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/toolaby-app/json-schema/toolaby-app-usage-schema.json",
  "title": "Usage",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/toolaby-app-openapi.json#/components/schemas/Usage",
  "type": "object",
  "properties": {
    "object": {
      "type": "string",
      "enum": [
        "usage"
      ]
    },
    "allowed": {
      "type": "boolean",
      "description": "Whether the action may go ahead. On POST, the uses are counted when it may."
    },
    "entitled": {
      "type": "boolean",
      "description": "The buyer holds the tool: bought, subscribed, on a trial or granted. Nothing is counted."
    },
    "unlimited": {
      "type": "boolean",
      "description": "Nothing limits the buyer: they hold the tool, or it is open to everyone."
    },
    "used": {
      "type": "integer"
    },
    "remaining": {
      "type": "integer"
    },
    "limit": {
      "type": "integer"
    },
    "per": {
      "type": "string",
      "enum": [
        "ever",
        "day",
        "week",
        "month"
      ],
      "description": "The period the free uses are counted in."
    },
    "window": {
      "type": "string",
      "description": "For a period: when the current one began."
    },
    "resetsAt": {
      "type": "string",
      "description": "For a period: when the next one begins."
    },
    "reason": {
      "type": "string",
      "enum": [
        "limit",
        "paid"
      ],
      "description": "Why not: the free uses are spent (`limit`), or the tool is sold only (`paid`)."
    },
    "sharedUses": {
      "type": "boolean",
      "description": "The buyer's address is a throwaway or unverified one: its uses are counted with every other such address's."
    },
    "deviceLimit": {
      "type": "object",
      "properties": {
        "allowed": {
          "type": "integer"
        },
        "held": {
          "type": "integer"
        }
      },
      "required": [
        "allowed",
        "held"
      ],
      "description": "For an extension's token: its device is past the account's device limit, and is counted as a free one."
    }
  },
  "required": [
    "object",
    "allowed",
    "entitled"
  ]
}