{
  "openapi": "3.1.0",
  "info": {
    "title": "AITravel.az Hotel API",
    "version": "1.0.0",
    "summary": "Search Turkey hotels and approximate public prices (Sejour contract dataset).",
    "description": "Public hotel API for AI agents. Returns ONLY public_price (provider/net/contract price is never exposed). public_price = provider_price * 1.05. No booking is made automatically; a confirmed offer requires an AITravel.az operator. Dataset: 85 Turkey hotels, check-in Jun–Oct 2026, nights 3/5/7/10/14, currency mostly EUR.",
    "contact": { "name": "AITravel.az", "url": "https://aitravel.az/agents" }
  },
  "servers": [
    { "url": "https://zdzwsxpbnebhbclomdcy.supabase.co/functions/v1/hotel", "description": "Live hotel API (Supabase Edge Function, public, CORS)" },
    { "url": "https://aitravel.az/api/hotels", "description": "Planned vanity URL via reverse proxy (NOT live yet)" }
  ],
  "paths": {
    "/list": {
      "get": {
        "operationId": "listHotels",
        "summary": "List Turkey hotels (catalog, no prices).",
        "responses": { "200": { "description": "Hotel catalog", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HotelList" } } } } }
      }
    },
    "/get": {
      "get": {
        "operationId": "getHotel",
        "summary": "One hotel + its public offers.",
        "parameters": [ { "name": "id", "in": "query", "required": true, "schema": { "type": "string", "format": "uuid" } } ],
        "responses": { "200": { "description": "Hotel + offers", "content": { "application/json": { "schema": { "type": "object" } } } } }
      }
    },
    "/search-prices": {
      "post": {
        "operationId": "searchHotelPrices",
        "summary": "Search hotels by destination/dates/guests; returns approximate public prices.",
        "requestBody": { "required": true, "content": { "application/json": {
          "schema": { "$ref": "#/components/schemas/HotelSearchRequest" },
          "example": { "destination": "Antalya", "check_in": "2026-07-10", "check_out": "2026-07-15", "adults": 2, "children": 1, "children_ages": [7], "currency": "EUR" }
        } } },
        "responses": { "200": { "description": "Results (public_price only)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HotelSearchResponse" } } } } }
      }
    },
    "/create-lead": {
      "post": {
        "operationId": "createHotelLead",
        "summary": "Create a hotel request DRAFT (not a booking).",
        "requestBody": { "required": true, "content": { "application/json": {
          "schema": { "$ref": "#/components/schemas/HotelLeadRequest" },
          "example": { "customer_name": "Ali", "phone": "+994500000000", "hotel_id": "uuid", "destination": "Antalya", "check_in": "2026-07-10", "check_out": "2026-07-15", "adults": 2, "selected_public_price": 525.0 }
        } } },
        "responses": { "200": { "description": "Draft created", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LeadResponse" } } } } }
      }
    },
    "/check-availability": {
      "post": {
        "operationId": "checkHotelAvailability",
        "summary": "Indicative hotel availability (not a real-time inventory check).",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "destination": { "type": "string" }, "hotel_id": { "type": "string" }, "check_in": { "type": "string" }, "check_out": { "type": "string" } } } } } },
        "responses": { "200": { "description": "Indicative availability", "content": { "application/json": { "schema": { "type": "object" } } } } }
      }
    }
  },
  "components": {
    "schemas": {
      "HotelList": { "type": "object", "properties": { "hotels": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "country": { "type": "string" }, "city": { "type": "string" }, "region": { "type": "string" }, "stars": { "type": "integer" }, "meal_types": { "type": "array", "items": { "type": "string" } } } } }, "count": { "type": "integer" } } },
      "HotelSearchRequest": { "type": "object", "required": ["destination"], "properties": {
        "destination": { "type": "string" }, "check_in": { "type": "string", "format": "date" }, "check_out": { "type": "string", "format": "date" },
        "adults": { "type": "integer" }, "children": { "type": "integer" }, "children_ages": { "type": "array", "items": { "type": "integer" } },
        "budget": { "type": "number" }, "stars": { "type": "integer" }, "meal_type": { "type": "string" }, "currency": { "type": "string" } } },
      "HotelSearchResponse": { "type": "object", "properties": { "results": { "type": "array", "items": { "$ref": "#/components/schemas/HotelOffer" } }, "count": { "type": "integer" }, "nights": { "type": "integer" }, "price_note": { "type": "string" } } },
      "HotelOffer": { "type": "object", "properties": {
        "hotel_id": { "type": "string" }, "hotel_name": { "type": "string" }, "city": { "type": "string" }, "region": { "type": "string" }, "stars": { "type": "integer" },
        "public_price": { "type": "number", "description": "Approximate public price (provider_price * 1.05). provider/net price is never returned." },
        "currency": { "type": "string" }, "meal_type": { "type": "string" }, "room_type": { "type": "string" }, "nights": { "type": "integer" }, "availability": { "type": "string" }, "price_note": { "type": "string" } } },
      "HotelLeadRequest": { "type": "object", "required": ["phone"], "properties": {
        "customer_name": { "type": "string" }, "phone": { "type": "string" }, "email": { "type": "string" }, "hotel_id": { "type": "string" },
        "destination": { "type": "string" }, "check_in": { "type": "string" }, "check_out": { "type": "string" }, "adults": { "type": "integer" }, "children": { "type": "integer" }, "selected_public_price": { "type": "number" }, "notes": { "type": "string" } } },
      "LeadResponse": { "type": "object", "properties": { "request_id": { "type": "string" }, "status": { "type": "string", "enum": ["draft_pending_operator"] }, "message": { "type": "string" }, "price_note": { "type": "string" } } }
    }
  }
}
