{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/threshold-rentals/json-schema/threshold-rentals-booking-schema.json",
  "title": "Booking",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/threshold-rentals-openapi.json#/components/schemas/Booking",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "confirmation_code": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "awaiting_payment",
        "pending_host_confirmation",
        "confirmed",
        "declined",
        "expired",
        "cancelled_by_guest",
        "cancelled_by_host",
        "cancelled_unpaid"
      ]
    },
    "property_id": {
      "type": "string"
    },
    "check_in": {
      "type": "string",
      "format": "date"
    },
    "check_out": {
      "type": "string",
      "format": "date"
    },
    "party": {
      "$ref": "#/$defs/Party"
    },
    "total": {
      "$ref": "#/$defs/Money"
    },
    "amount_paid": {
      "$ref": "#/$defs/Money"
    },
    "amount_refunded": {
      "$ref": "#/$defs/Money"
    },
    "refund_schedule": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/RefundTier"
      }
    },
    "payment": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "collected_by": {
          "type": "string",
          "enum": [
            "threshold",
            "host"
          ]
        },
        "status": {
          "type": "string"
        },
        "plan": {
          "type": "string"
        },
        "payment_url": {
          "type": "string",
          "format": "uri",
          "description": "Present when the guest still has to pay"
        },
        "charge_date": {
          "type": "string",
          "format": "date-time"
        },
        "pay_by": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "host_confirm_by": {
      "type": "string",
      "format": "date-time"
    },
    "arrival_info_available_at": {
      "type": "string",
      "format": "date-time"
    },
    "arrival_info_sent_at": {
      "type": "string",
      "format": "date-time"
    },
    "special_requests": {
      "type": "string"
    },
    "host_message": {
      "type": "string"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "Money": {
      "type": "object",
      "required": [
        "amount",
        "currency"
      ],
      "properties": {
        "amount": {
          "type": "integer",
          "description": "In cents"
        },
        "currency": {
          "type": "string"
        }
      }
    },
    "Party": {
      "type": "object",
      "properties": {
        "adults": {
          "type": "integer",
          "minimum": 1,
          "default": 1
        },
        "children": {
          "type": "integer",
          "minimum": 0
        },
        "infants": {
          "type": "integer",
          "minimum": 0
        },
        "pets": {
          "type": "integer",
          "minimum": 0
        },
        "service_animals": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "RefundTier": {
      "type": "object",
      "properties": {
        "until": {
          "type": "string",
          "format": "date-time",
          "description": "Cancel before this time…"
        },
        "refund": {
          "$ref": "#/$defs/Money",
          "description": "…to get this back"
        }
      }
    }
  }
}