{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/buyrecord-app/json-schema/buyrecord-app-stay-submission-schema.json",
  "title": "StaySubmission",
  "x-generated": "2026-11-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/buyrecord-app-openapi.json#/components/schemas/StaySubmission",
  "properties": {
    "property_name": {
      "type": "string",
      "maxLength": 200,
      "minLength": 3,
      "title": "Property Name",
      "description": "Property name exactly as in the email."
    },
    "city": {
      "type": "string",
      "maxLength": 100,
      "minLength": 2,
      "title": "City",
      "description": "City exactly as in the email."
    },
    "check_in": {
      "type": "string",
      "format": "date",
      "title": "Check In"
    },
    "check_out": {
      "type": "string",
      "format": "date",
      "title": "Check Out"
    },
    "outcome": {
      "type": "string",
      "enum": [
        "stayed_as_described",
        "stayed_with_issues",
        "cancelled_by_property",
        "left_early"
      ],
      "title": "Outcome"
    },
    "reasons": {
      "items": {
        "type": "string",
        "enum": [
          "not_as_described",
          "cleanliness",
          "noise",
          "check_in_problem",
          "safety",
          "overbooked",
          "other"
        ]
      },
      "type": "array",
      "maxItems": 7,
      "title": "Reasons"
    },
    "proof": {
      "$ref": "#/$defs/StayConfirmationProof"
    }
  },
  "type": "object",
  "required": [
    "property_name",
    "city",
    "check_in",
    "check_out",
    "outcome",
    "proof"
  ],
  "$defs": {
    "StayConfirmationProof": {
      "properties": {
        "type": {
          "type": "string",
          "const": "stay_confirmation",
          "title": "Type"
        },
        "raw_email_base64": {
          "type": "string",
          "maxLength": 2800000,
          "title": "Raw Email Base64",
          "description": "The platform's original booking confirmation email (.eml, RFC 5322), base64-encoded. Its DKIM signature is verified; the email is processed in memory once and never stored."
        },
        "reservation_number": {
          "type": "string",
          "maxLength": 60,
          "minLength": 4,
          "title": "Reservation Number",
          "description": "Reservation or confirmation number as it appears in the email. Hashed on arrival, never stored."
        }
      },
      "type": "object",
      "required": [
        "type",
        "raw_email_base64",
        "reservation_number"
      ],
      "title": "StayConfirmationProof"
    }
  }
}