{
 "openapi": "3.0.3",
 "info": {
  "title": "RoomAnalyzer API",
  "version": "1.0.0",
  "description": "Room photos in, a budget-checked plan of reversible changes out. Scores, costs, fits and restriction checks are computed and re-verified in code; a guide, not a survey. Only POST /analyses is billed, after success."
 },
 "servers": [
  {
   "url": "https://roomanalyzer.sensifai.com"
  }
 ],
 "security": [
  {
   "ApiKey": []
  },
  {
   "Bearer": []
  }
 ],
 "paths": {
  "/api/v1/meta": {
   "get": {
    "summary": "Closed vocabularies (room types, styles, restrictions, kinds, tags, colours)",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Meta"
        }
       }
      }
     },
     "401": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/preview": {
   "post": {
    "summary": "Free photo preview: quality, light and measured palette (no AI)",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/PreviewRequest"
       }
      },
      "multipart/form-data": {
       "schema": {
        "type": "object",
        "properties": {
         "photo": {
          "type": "array",
          "items": {
           "type": "string",
           "format": "binary"
          },
          "maxItems": 3
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Preview"
        }
       }
      }
     },
     "401": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     },
     "422": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/analyses": {
   "post": {
    "summary": "Start an analysis (billed once delivered)",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/StartRequest"
       }
      },
      "multipart/form-data": {
       "schema": {
        "type": "object",
        "properties": {
         "photo": {
          "type": "array",
          "items": {
           "type": "string",
           "format": "binary"
          },
          "maxItems": 3
         },
         "room_type": {
          "type": "string"
         },
         "style": {
          "type": "string"
         },
         "budget_eur": {
          "type": "integer"
         },
         "purpose": {
          "type": "array",
          "items": {
           "type": "string"
          }
         },
         "restriction": {
          "type": "array",
          "items": {
           "type": "string"
          }
         },
         "avoid_family": {
          "type": "array",
          "items": {
           "type": "string"
          }
         },
         "width_cm": {
          "type": "integer"
         },
         "length_cm": {
          "type": "integer"
         },
         "height_cm": {
          "type": "integer"
         },
         "room_id": {
          "type": "string"
         },
         "language": {
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "202": {
      "description": "Accepted",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Accepted"
        }
       }
      }
     },
     "401": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     },
     "402": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     },
     "403": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     },
     "422": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     },
     "429": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     }
    }
   },
   "get": {
    "summary": "List analyses",
    "parameters": [
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "offset",
      "in": "query",
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/AnalysisSummary"
         }
        }
       }
      }
     },
     "401": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/analyses/{id}": {
   "get": {
    "summary": "One delivered analysis (the report)",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/AnalysisView"
        }
       }
      }
     },
     "401": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     },
     "404": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/analyses/{id}/replan": {
   "post": {
    "summary": "Free what-if: confirm or correct elements, change budget, restrictions or dimensions; recomputed in code, not persisted",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ReplanRequest"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The recomputed report",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Report"
        }
       }
      }
     },
     "401": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     },
     "404": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     },
     "422": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/jobs/{id}": {
   "get": {
    "summary": "Poll an analysis job",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Job"
        }
       }
      }
     },
     "401": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     },
     "404": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/history": {
   "get": {
    "summary": "Aggregates over delivered analyses (weekly scores, colours, tags, room types)",
    "parameters": [
     {
      "name": "days",
      "in": "query",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "room_id",
      "in": "query",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "401": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/rooms": {
   "get": {
    "summary": "Saved rooms",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/Room"
         }
        }
       }
      }
     },
     "401": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     }
    }
   },
   "post": {
    "summary": "Save a room",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/RoomInput"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Created",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Room"
        }
       }
      }
     },
     "401": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     },
     "409": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     },
     "422": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/rooms/{id}": {
   "delete": {
    "summary": "Delete a saved room and its tracked plan items",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "204": {
      "description": "Deleted"
     },
     "401": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     },
     "404": {
      "description": "Problem",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "securitySchemes": {
   "ApiKey": {
    "type": "apiKey",
    "in": "header",
    "name": "X-API-Key"
   },
   "Bearer": {
    "type": "http",
    "scheme": "bearer"
   }
  },
  "schemas": {
   "Problem": {
    "type": "object",
    "properties": {
     "type": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "status": {
      "type": "integer"
     },
     "detail": {
      "type": "string"
     },
     "code": {
      "type": "string"
     }
    }
   },
   "Dims": {
    "type": "object",
    "properties": {
     "width_cm": {
      "type": "integer",
      "minimum": 100,
      "maximum": 2000
     },
     "length_cm": {
      "type": "integer",
      "minimum": 100,
      "maximum": 2000
     },
     "height_cm": {
      "type": "integer"
     }
    }
   },
   "Meta": {
    "type": "object",
    "description": "room_types, purposes, styles, restrictions, kinds, tags, colors, families, languages, dimensions"
   },
   "PreviewRequest": {
    "type": "object",
    "required": [
     "photos"
    ],
    "properties": {
     "photos": {
      "type": "array",
      "minItems": 1,
      "maxItems": 3,
      "items": {
       "type": "string",
       "description": "base64 JPEG or PNG (a data: URL is accepted)"
      }
     }
    }
   },
   "Preview": {
    "type": "object",
    "description": "image_quality, photo_quality[], measured (brightness, evenness, dark_share, glare_share, busyness, cast, palette[]), notes[], thumbnail"
   },
   "StartRequest": {
    "type": "object",
    "required": [
     "photos"
    ],
    "properties": {
     "photos": {
      "type": "array",
      "minItems": 1,
      "maxItems": 3,
      "items": {
       "type": "string"
      }
     },
     "room_id": {
      "type": "string",
      "description": "a saved room fills whatever is omitted"
     },
     "language": {
      "type": "string",
      "enum": [
       "en",
       "nl",
       "fr",
       "de",
       "es"
      ]
     },
     "room_type": {
      "type": "string",
      "example": "living_room"
     },
     "purposes": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "example": [
       "relax"
      ]
     },
     "style": {
      "type": "string",
      "example": "scandi"
     },
     "budget_eur": {
      "type": "integer",
      "minimum": 0,
      "maximum": 20000,
      "example": 150
     },
     "dims": {
      "$ref": "#/components/schemas/Dims"
     },
     "restrictions": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "example": [
       "no_paint"
      ]
     },
     "avoid_families": {
      "type": "array",
      "items": {
       "type": "string"
      }
     }
    }
   },
   "Accepted": {
    "type": "object",
    "properties": {
     "job_id": {
      "type": "string"
     },
     "status": {
      "type": "string"
     },
     "poll": {
      "type": "string"
     }
    }
   },
   "Job": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "status": {
      "type": "string",
      "enum": [
       "queued",
       "running",
       "succeeded",
       "failed"
      ]
     },
     "analysis_id": {
      "type": "string"
     },
     "room_type": {
      "type": "string"
     },
     "error": {
      "type": "string"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "AnalysisSummary": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "status": {
      "type": "string"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "room_type": {
      "type": "string"
     },
     "style": {
      "type": "string"
     },
     "overall": {
      "type": "integer"
     },
     "steps": {
      "type": "integer"
     },
     "plan_min_eur": {
      "type": "integer"
     },
     "plan_max_eur": {
      "type": "integer"
     },
     "budget_eur": {
      "type": "integer"
     }
    }
   },
   "AnalysisView": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "result": {
      "$ref": "#/components/schemas/Report"
     },
     "units": {
      "type": "integer"
     },
     "cost_eur": {
      "type": "number"
     }
    }
   },
   "Report": {
    "type": "object",
    "description": "The proposal's output contract: room_elements, visual_observations, palette, priorities, plan.steps (suggested_changes), plan totals and per-step cost bands (cost_ranges), measurement_requests; plus scores with evidence, checks, plan_checks, advisories, shopping_list, mood_board.",
    "properties": {
     "room_elements": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "visual_observations": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "palette": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "priorities": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "plan": {
      "type": "object",
      "properties": {
       "steps": {
        "type": "array",
        "items": {
         "type": "object"
        }
       },
       "budget_eur": {
        "type": "integer"
       },
       "total_min_eur": {
        "type": "integer"
       },
       "total_max_eur": {
        "type": "integer"
       },
       "within_budget": {
        "type": "boolean"
       }
      }
     },
     "measurement_requests": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "scores": {
      "type": "object"
     },
     "checks": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "plan_checks": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "advisories": {
      "type": "array",
      "items": {
       "type": "string"
      }
     }
    }
   },
   "ReplanRequest": {
    "type": "object",
    "properties": {
     "elements": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "id": {
         "type": "string"
        },
        "kind": {
         "type": "string"
        },
        "count": {
         "type": "integer"
        },
        "palette_id": {
         "type": "string"
        },
        "hex": {
         "type": "string"
        }
       }
      }
     },
     "context": {
      "type": "object",
      "properties": {
       "room_type": {
        "type": "string",
        "example": "living_room"
       },
       "purposes": {
        "type": "array",
        "items": {
         "type": "string"
        },
        "example": [
         "relax"
        ]
       },
       "style": {
        "type": "string",
        "example": "scandi"
       },
       "budget_eur": {
        "type": "integer",
        "minimum": 0,
        "maximum": 20000,
        "example": 150
       },
       "dims": {
        "$ref": "#/components/schemas/Dims"
       },
       "restrictions": {
        "type": "array",
        "items": {
         "type": "string"
        },
        "example": [
         "no_paint"
        ]
       },
       "avoid_families": {
        "type": "array",
        "items": {
         "type": "string"
        }
       },
       "clear_dims": {
        "type": "boolean"
       }
      }
     }
    }
   },
   "RoomInput": {
    "type": "object",
    "required": [
     "name",
     "room_type"
    ],
    "properties": {
     "name": {
      "type": "string"
     },
     "room_type": {
      "type": "string"
     },
     "purposes": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "style": {
      "type": "string"
     },
     "budget_eur": {
      "type": "integer"
     },
     "width_cm": {
      "type": "integer"
     },
     "length_cm": {
      "type": "integer"
     },
     "height_cm": {
      "type": "integer"
     },
     "restrictions": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "avoid_families": {
      "type": "array",
      "items": {
       "type": "string"
      }
     }
    }
   },
   "Room": {
    "allOf": [
     {
      "$ref": "#/components/schemas/RoomInput"
     },
     {
      "type": "object",
      "properties": {
       "id": {
        "type": "string"
       },
       "created_at": {
        "type": "string",
        "format": "date-time"
       },
       "updated_at": {
        "type": "string",
        "format": "date-time"
       }
      }
     }
    ]
   }
  }
 }
}