{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/hemrock-com/json-schema/hemrock-com-access-response-schema.json",
  "title": "AccessResponse",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hemrock-com-openapi.json#/components/schemas/AccessResponse",
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "required": [
        "products",
        "daily"
      ],
      "properties": {
        "products": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ProductAccess"
          }
        },
        "daily": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DailyUsage"
          }
        },
        "monthly": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/MonthlyUsage"
          }
        },
        "periods": {
          "type": "array",
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/UsagePeriod"
              },
              {
                "type": "object",
                "required": [
                  "product"
                ],
                "properties": {
                  "product": {
                    "type": "string",
                    "enum": [
                      "cap-table",
                      "fund-economics"
                    ]
                  }
                }
              }
            ]
          }
        }
      }
    }
  },
  "$defs": {
    "DailyUsage": {
      "type": "object",
      "required": [
        "day",
        "product",
        "endpoint",
        "source",
        "succeeded",
        "failed"
      ],
      "properties": {
        "day": {
          "type": "string",
          "format": "date"
        },
        "product": {
          "type": "string",
          "enum": [
            "cap-table",
            "fund-economics"
          ]
        },
        "endpoint": {
          "type": "string"
        },
        "source": {
          "type": "string"
        },
        "succeeded": {
          "type": "integer"
        },
        "failed": {
          "type": "integer"
        }
      }
    },
    "MonthlyUsage": {
      "type": "object",
      "required": [
        "month",
        "product",
        "succeeded",
        "failed"
      ],
      "properties": {
        "month": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}$"
        },
        "product": {
          "type": "string",
          "enum": [
            "cap-table",
            "fund-economics"
          ]
        },
        "succeeded": {
          "type": "integer"
        },
        "failed": {
          "type": "integer"
        }
      }
    },
    "ProductAccess": {
      "type": "object",
      "required": [
        "product",
        "name",
        "priceUsd",
        "allowance",
        "period",
        "remaining",
        "active"
      ],
      "properties": {
        "product": {
          "type": "string",
          "enum": [
            "cap-table",
            "fund-economics"
          ]
        },
        "name": {
          "type": "string"
        },
        "priceUsd": {
          "type": "number",
          "const": 20
        },
        "allowance": {
          "type": "integer",
          "const": 6000
        },
        "period": {
          "anyOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/$defs/UsagePeriod"
            }
          ]
        },
        "remaining": {
          "type": "integer",
          "minimum": 0,
          "description": "Calculations this account can run now: the paid balance while a paid period is active, otherwise the lifetime free balance."
        },
        "active": {
          "type": "boolean",
          "description": "Active paid term; use state/freeRemaining for trial access."
        },
        "state": {
          "type": "string",
          "enum": [
            "free_available",
            "free_exhausted",
            "paid_active",
            "paid_expired",
            "paid_quota_exhausted"
          ]
        },
        "source": {
          "type": "string",
          "enum": [
            "free",
            "paid"
          ]
        },
        "freeRemaining": {
          "type": "integer",
          "minimum": 0
        },
        "paidRemaining": {
          "type": "integer",
          "minimum": 0
        },
        "paidExpiration": {
          "type": [
            "string",
            "null"
          ]
        },
        "nextAction": {
          "type": "string"
        }
      }
    },
    "UsagePeriod": {
      "type": "object",
      "required": [
        "id",
        "period_start",
        "period_end",
        "allowance",
        "consumed",
        "reserved",
        "enabled"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "period_start": {
          "type": "string",
          "format": "date-time"
        },
        "period_end": {
          "type": "string",
          "format": "date-time"
        },
        "allowance": {
          "type": "integer"
        },
        "consumed": {
          "type": "integer"
        },
        "reserved": {
          "type": "integer"
        },
        "enabled": {
          "type": "boolean"
        }
      }
    }
  }
}