{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/rentalcal-com/json-schema/rentalcal-com-availability-schema.json",
  "title": "Availability",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/rentalcal-com-openapi.yml#/components/schemas/Availability",
  "type": "object",
  "required": [
    "window",
    "minNights",
    "bookableFrom",
    "unavailable",
    "openGaps"
  ],
  "properties": {
    "window": {
      "type": "object",
      "properties": {
        "from": {
          "type": "string",
          "format": "date",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
          "description": "Inclusive."
        },
        "to": {
          "type": "string",
          "format": "date",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
          "description": "Exclusive."
        }
      }
    },
    "minNights": {
      "type": "integer"
    },
    "checkInDayMinNights": {
      "$ref": "#/$defs/CheckInDayMinNights"
    },
    "bookableFrom": {
      "type": "string",
      "format": "date",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      "description": "First check-in a request made now may ask for: today in the property's timezone, or later when the host requires notice (`booking.minAdvanceHours`). Open gaps start here."
    },
    "bookableUntil": {
      "type": [
        "string",
        "null"
      ],
      "format": "date",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      "description": "First night not yet open for booking: the host's window, or 24 months from today by default, so it is no longer null. Open gaps stop here; the nights after it are not listed as unavailable because nobody holds them."
    },
    "seasonalMinNights": {
      "type": "array",
      "description": "Overrides by check-in date.",
      "items": {
        "type": "object",
        "properties": {
          "startDate": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": ""
          },
          "endDate": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "Inclusive."
          },
          "minNights": {
            "type": "integer"
          }
        }
      }
    },
    "unavailable": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DateRange"
      },
      "description": "Nights already booked or blocked."
    },
    "openGaps": {
      "type": "array",
      "description": "Runs of free nights that a quote would accept a stay in. Seasonal minimums and gap fill are applied, and no gap starts before today.",
      "items": {
        "type": "object",
        "properties": {
          "start": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "First free night."
          },
          "end": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "Latest checkout."
          },
          "nights": {
            "type": "integer",
            "description": "Free nights in the gap."
          }
        }
      }
    }
  },
  "$defs": {
    "CheckInDayMinNights": {
      "type": "array",
      "description": "Minimums by the check-in's day of the week, 0 = Sunday. Overrides `minNights`; a seasonal rule still wins on its dates.",
      "items": {
        "type": "object",
        "required": [
          "weekday",
          "minNights"
        ],
        "properties": {
          "weekday": {
            "type": "integer",
            "minimum": 0,
            "maximum": 6
          },
          "minNights": {
            "type": "integer"
          }
        }
      }
    },
    "DateRange": {
      "type": "object",
      "required": [
        "from",
        "to"
      ],
      "properties": {
        "from": {
          "type": "string",
          "format": "date",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
          "description": "First night (inclusive)."
        },
        "to": {
          "type": "string",
          "format": "date",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
          "description": "Checkout day (exclusive)."
        }
      }
    }
  }
}