{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/smarterdata/json-schema/smarterdata-usage-schema.json",
  "title": "Usage",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/smarterdata-openapi.json#/components/schemas/Usage",
  "type": "object",
  "required": [
    "ok",
    "usage",
    "ledger"
  ],
  "properties": {
    "ok": {
      "type": "boolean"
    },
    "usage": {
      "type": "array",
      "description": "The last 30 days, one entry per action that was charged.",
      "items": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "description": "A key of the price table, e.g. company_search."
          },
          "units": {
            "type": "integer",
            "description": "Net credits: refunds taken off."
          },
          "calls": {
            "type": "integer"
          }
        }
      }
    },
    "ledger": {
      "type": "array",
      "description": "The last 25 ledger entries, newest first.",
      "items": {
        "type": "object",
        "properties": {
          "delta": {
            "type": [
              "integer",
              "string"
            ],
            "description": "Credits added (above 0) or taken (below 0). A whole number, which may arrive as a string."
          },
          "reason": {
            "type": "string"
          },
          "balance_after": {
            "type": [
              "integer",
              "string",
              "null"
            ],
            "description": "The balance after this entry. A whole number, which may arrive as a string."
          },
          "shortfall": {
            "type": [
              "integer",
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  }
}