{
  "openapi": "3.1.0",
  "info": {
    "title": "TailorLens API",
    "version": "1",
    "description": "From photo to pattern. Send one to five photos of a garment and get four connected deliverables from one versioned specification: a fashion sketch, technical flats, a size-adjusted sewing pattern (SVG and tiled PDF) and colour palettes. The model only observes; geometry, measurements, palettes and every check are computed in code, and every fact is labelled observed, inferred, confirmed, template_default or not_verifiable. A pattern is exported only for a reviewed block whose geometry checks all pass, and says what it is: measured_draft (every required measurement typed, from a chart you confirmed or from a garment you measured), standard_draft (a labelled standard reference size, EU 40 by default, filled the values you gave none for) or approximate_draft (the closest basic block, with the features it does not draft listed); garments no basic block can represent stay conceptual. Every draft is a starting point, not proof of fit. Authenticate with an API key (Authorization: Bearer <key> or X-API-Key). Only starting an analysis is billed, after it succeeds; the preview, spec edits, recolouring, every render and export, projects, the revision diff, comparison, share links and history are free."
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "security": [
    {
      "bearer": []
    },
    {
      "apiKey": []
    }
  ],
  "paths": {
    "/api/v1/meta": {
      "get": {
        "summary": "Vocabularies and guidance",
        "operationId": "getMeta",
        "tags": [
          "Reference"
        ],
        "description": "The closed lists a request may use (families, templates, features and their values, measurements, size charts, palette roles), the five evidence labels and the four limits. Free.",
        "responses": {
          "200": {
            "description": "Vocabularies",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetaView"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/preview": {
      "post": {
        "summary": "Check photo quality (free)",
        "operationId": "previewPhotos",
        "tags": [
          "Analysis"
        ],
        "description": "Measures each photo locally (sharpness, exposure, resolution, garment coverage, measured colours) and returns specific tips. No AI is used and nothing is billed or stored. Send JSON with base64 photos, or multipart with `photos` files and `roles`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewRequest"
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "photos": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    },
                    "description": "One to five JPEG or PNG files (up to 15 MB each), repeat the field."
                  },
                  "roles": {
                    "type": "string",
                    "description": "Comma-separated roles, one per photo in order (front, back, side, detail, flat); may be repeated. Default by position: front, back, side, detail, flat."
                  }
                },
                "required": [
                  "photos"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-photo measurements",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreviewView"
                }
              }
            }
          },
          "413": {
            "description": "A photo is too large"
          },
          "415": {
            "description": "A photo is not a JPEG or PNG (WebP and HEIC get a specific message)"
          },
          "422": {
            "description": "Invalid roles or photo count"
          },
          "429": {
            "description": "Hourly preview quota reached"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/analyses": {
      "post": {
        "summary": "Start an analysis (billed on success)",
        "operationId": "startAnalysis",
        "tags": [
          "Analysis"
        ],
        "description": "Queues one analysis of one to five photos of a single garment and returns 202 with a job to poll. It is billed only when the report is delivered, under one identifier minted here; an unusable photo (422), a photo set with no garment, a refusal or a failure bills nothing. Send JSON with base64 `photos`, or multipart with `photos` files, `roles`, `facts` (JSON) and optional `project_id`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartRequest"
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "photos": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    },
                    "description": "One to five JPEG or PNG files (up to 15 MB each), repeat the field."
                  },
                  "roles": {
                    "type": "string",
                    "description": "Comma-separated roles, one per photo in order (front, back, side, detail, flat); may be repeated. Default by position: front, back, side, detail, flat."
                  },
                  "facts": {
                    "type": "string",
                    "description": "JSON object of customer facts (see Facts)."
                  },
                  "project_id": {
                    "type": "string"
                  },
                  "output_language": {
                    "type": "string",
                    "description": "Optional UI locale code for the model's free text (one of the 19 StartRequest.output_language values)."
                  }
                },
                "required": [
                  "photos"
                ]
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Accepted"
                }
              }
            }
          },
          "402": {
            "description": "Empty wallet (body carries top_up_url)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "No active subscription (body carries subscribe_url)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "413": {
            "description": "A photo is too large"
          },
          "415": {
            "description": "A photo is not a JPEG or PNG"
          },
          "422": {
            "description": "Invalid input, including an unusable photo (errors[] names photos[N] and why) or invalid facts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Too many analyses running or the hourly quota reached"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "get": {
        "summary": "List analyses",
        "operationId": "listAnalyses",
        "tags": [
          "Analysis"
        ],
        "description": "Your analyses, newest first. Query: limit (1-100), before (RFC 3339 or Unix seconds), family, status (a report status). Free.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "before",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "family",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "skirt",
                "trouser",
                "top",
                "dress",
                "coat",
                "other"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "measured_draft",
                "standard_draft",
                "approximate_draft",
                "needs_measurements",
                "conceptual",
                "blocked"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Analyses",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AnalysisSummary"
                  }
                }
              }
            }
          },
          "422": {
            "description": "Invalid filter"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/analyses/{id}": {
      "get": {
        "summary": "Fetch an analysis",
        "operationId": "getAnalysis",
        "tags": [
          "Analysis"
        ],
        "description": "The delivered report. Free.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The analysis",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnalysisView"
                }
              }
            }
          },
          "404": {
            "description": "Unknown or no longer retained"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "delete": {
        "summary": "Delete an analysis",
        "operationId": "deleteAnalysis",
        "tags": [
          "Analysis"
        ],
        "description": "Removes the report, its history row, its project link, feedback and share links. Free.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "404": {
            "description": "Unknown"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/analyses/{id}/spec": {
      "patch": {
        "summary": "Edit the garment spec (free)",
        "operationId": "editSpec",
        "tags": [
          "Analysis"
        ],
        "description": "Apply Edits: confirm or correct features, the template, the size and chart, measurements, options, and choose or recolour a palette. Everything dependent is recomputed locally with no model call and no charge; the stored report becomes the next revision. A palette edit never changes the pattern geometry.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Edits"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated analysis",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnalysisView"
                }
              }
            }
          },
          "404": {
            "description": "Unknown"
          },
          "422": {
            "description": "An edit that cannot be applied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/analyses/{id}/exports/{format}": {
      "get": {
        "summary": "Download an export (free)",
        "operationId": "exportAnalysis",
        "tags": [
          "Analysis"
        ],
        "description": "One file built from the stored report: the design package (zip), the specification (json), the summary sheet (md), the sketch, flats or palette (svg) and, only for a measured, standard-size or approximate draft, the pattern (svg, or tiled pdf; query paper=a4|letter|a3|tabloid). The pattern formats answer 409 with the reasons for a conceptual garment or a failed geometry check. Every file carries the status line (a standard-size or approximate draft says so in full) and the four limits.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "package.zip",
                "json",
                "md",
                "sketch.svg",
                "flats.svg",
                "palette.svg",
                "pattern.svg",
                "pattern.pdf"
              ]
            }
          },
          {
            "name": "paper",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "a4",
                "letter",
                "a3",
                "tabloid"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The file (Content-Disposition: attachment)",
            "content": {
              "application/zip": {},
              "application/json": {},
              "text/markdown": {},
              "image/svg+xml": {},
              "application/pdf": {}
            }
          },
          "404": {
            "description": "Unknown"
          },
          "409": {
            "description": "The output is blocked: the garment is conceptual or a geometry check failed (errors[] carries one reason each)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Unknown format or paper"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/jobs/{id}": {
      "get": {
        "summary": "Poll a job",
        "operationId": "getJob",
        "tags": [
          "Analysis"
        ],
        "description": "Status of a queued analysis. When status is succeeded, analysis_id names the report.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobView"
                }
              }
            }
          },
          "404": {
            "description": "Unknown"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      },
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing or invalid API key",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          },
          "timestamp": {
            "type": "integer"
          },
          "top_up_url": {
            "type": "string"
          },
          "subscribe_url": {
            "type": "string"
          }
        },
        "required": [
          "status",
          "title",
          "code"
        ],
        "description": "RFC 7807 problem details. A blocked output answers 409 with code BLOCKED and one errors[] entry (field reasons) per reason (conceptual garment or failed geometry check)."
      },
      "Option": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "help": {
            "type": "string"
          }
        }
      },
      "Check": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "ok": {
            "type": "boolean"
          },
          "detail": {
            "type": "string"
          }
        }
      },
      "Accepted": {
        "type": "object",
        "properties": {
          "job_id": {
            "type": "string"
          },
          "analysis_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed"
            ]
          },
          "poll": {
            "type": "string"
          }
        },
        "required": [
          "job_id",
          "analysis_id",
          "status",
          "poll"
        ]
      },
      "JobView": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed"
            ]
          },
          "analysis_id": {
            "type": "string"
          },
          "error": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "status"
        ]
      },
      "PhotoUpload": {
        "type": "object",
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "front",
              "back",
              "side",
              "detail",
              "flat"
            ]
          },
          "filename": {
            "type": "string"
          },
          "data": {
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "description": "One photo as base64 (a data: URL is accepted). JPEG or PNG, up to 15 MB. A photo with no role takes the role of its position."
      },
      "PreviewRequest": {
        "type": "object",
        "properties": {
          "photos": {
            "type": "array",
            "minItems": 1,
            "maxItems": 5,
            "items": {
              "$ref": "#/components/schemas/PhotoUpload"
            }
          }
        },
        "required": [
          "photos"
        ]
      },
      "StartRequest": {
        "type": "object",
        "properties": {
          "photos": {
            "type": "array",
            "minItems": 1,
            "maxItems": 5,
            "items": {
              "$ref": "#/components/schemas/PhotoUpload"
            }
          },
          "facts": {
            "$ref": "#/components/schemas/Facts"
          },
          "project_id": {
            "type": "string"
          },
          "output_language": {
            "type": "string",
            "description": "Optional UI locale the free text (summary, palette names and reasons) is written in. Unset means English. Not stored with the report.",
            "enum": [
              "en",
              "zh",
              "hi",
              "es",
              "fr",
              "ar",
              "bn",
              "pt",
              "ru",
              "ur",
              "id",
              "de",
              "ja",
              "fa",
              "tr",
              "ko",
              "it",
              "vi",
              "he"
            ]
          }
        },
        "required": [
          "photos"
        ]
      },
      "SizeInput": {
        "type": "object",
        "properties": {
          "system": {
            "type": "string",
            "enum": [
              "eu",
              "uk",
              "us",
              "custom"
            ]
          },
          "value": {
            "type": "string"
          },
          "chart_id": {
            "type": "string",
            "description": "A chart id from /meta. A size number alone is never universal. With chart_confirmed false, a chart size is only a choice of standard reference size, never your measurements."
          },
          "chart_confirmed": {
            "type": "boolean",
            "description": "You confirm this chart applies; chart values count as confirmed (a measured draft) only then. Without it the chosen size is a labelled standard size."
          }
        }
      },
      "Options": {
        "type": "object",
        "properties": {
          "fit": {
            "type": "string",
            "enum": [
              "close",
              "regular",
              "relaxed"
            ]
          },
          "ease_mm": {
            "type": "object",
            "additionalProperties": {
              "type": "number"
            }
          },
          "length_mm": {
            "type": "number"
          },
          "sleeve_length_mm": {
            "type": "number"
          },
          "seam_allowance_mm": {
            "type": "number"
          },
          "hem_allowance_mm": {
            "type": "number"
          },
          "stretch": {
            "type": "string",
            "enum": [
              "none",
              "low",
              "medium"
            ]
          },
          "drape": {
            "type": "string",
            "enum": [
              "crisp",
              "medium",
              "fluid"
            ]
          },
          "lined": {
            "type": "boolean"
          },
          "lapel_width_mm": {
            "type": "number",
            "minimum": 40,
            "maximum": 160
          },
          "construction": {
            "type": "string",
            "enum": [
              "princess",
              "dart"
            ],
            "description": "Formal gown or tailored jacket: princess seams or darts. Default princess (gown), dart (jacket)."
          },
          "skirt_style": {
            "type": "string",
            "enum": [
              "a_line",
              "column",
              "mermaid"
            ],
            "description": "Formal gown skirt. Default a_line."
          },
          "neckline": {
            "type": "string",
            "enum": [
              "sweetheart",
              "v_neck",
              "scoop",
              "square",
              "boat",
              "straight_strapless"
            ],
            "description": "Formal gown neckline. Default sweetheart, or the neckline read from the photos (labelled observed)."
          },
          "straps": {
            "type": "string",
            "enum": [
              "none",
              "wide",
              "spaghetti"
            ],
            "description": "Formal gown straps. Wide or spaghetti straps also need the shoulder and neck measurements."
          },
          "neckline_depth": {
            "type": "string",
            "enum": [
              "medium",
              "shallow",
              "deep"
            ],
            "description": "Formal gown front neckline depth. Default medium, or the depth read from the photos (labelled observed)."
          },
          "back_style": {
            "type": "string",
            "enum": [
              "plain",
              "low",
              "open"
            ],
            "description": "Formal gown back neckline: plain, low or open. Default plain, or the back read from a photo of the back."
          },
          "slit": {
            "type": "string",
            "enum": [
              "none",
              "front",
              "side",
              "back"
            ],
            "description": "Formal gown skirt slit. A mark on the skirt only, never a drafted opening; the position is not read from the photos, a slit seen is marked at the front and labelled inferred."
          },
          "train_mm": {
            "type": "number",
            "minimum": 0,
            "maximum": 1500,
            "description": "Formal gown train beyond the floor-length hem at the centre back."
          },
          "vent": {
            "type": "string",
            "enum": [
              "none",
              "centre",
              "side"
            ],
            "description": "Tailored jacket back vent. Default none."
          },
          "lapel": {
            "type": "string",
            "enum": [
              "notch",
              "peak",
              "shawl"
            ],
            "description": "Tailored jacket lapel. Default notch, or read from the collar in the photos."
          },
          "breasted": {
            "type": "string",
            "enum": [
              "single",
              "double"
            ],
            "description": "Tailored jacket front. Default single, or read from the closure in the photos."
          },
          "back_detail": {
            "type": "string",
            "enum": [
              "none",
              "box_pleat",
              "darts"
            ],
            "description": "Dress shirt back yoke detail."
          },
          "cuff": {
            "type": "string",
            "enum": [
              "barrel",
              "french"
            ],
            "description": "Dress shirt cuff."
          },
          "collar": {
            "type": "string",
            "enum": [
              "point",
              "spread",
              "button_down"
            ],
            "description": "Dress shirt collar."
          },
          "chest_pocket": {
            "type": "boolean",
            "description": "Dress shirt left chest pocket."
          },
          "no_lining": {
            "type": "boolean",
            "description": "Formal gown or tailored jacket without a lining (the same as lined=false); contradicts lined=true."
          }
        },
        "description": "Construction choices; omitted means the block default (labelled template_default)."
      },
      "Facts": {
        "type": "object",
        "properties": {
          "size": {
            "$ref": "#/components/schemas/SizeInput"
          },
          "measurements_mm": {
            "type": "object",
            "additionalProperties": {
              "type": "number"
            },
            "description": "Confirmed body measurements in millimetres, keys from /meta measurements. Never inferred from a photo."
          },
          "garment_mm": {
            "type": "object",
            "additionalProperties": {
              "type": "number"
            },
            "description": "Optional measurements of a garment you own that fits well, in millimetres, keys from /meta garment_measurements (chest, waist, hip, shoulder, length, sleeve_length, inseam, rise, hip_depth, back_length, neck, upper_arm, wrist). They are FINISHED-garment dimensions, so circumferences include the ease built into the garment: next to a body measurement they set the ease (garment minus body); without one they are turned into a body-equivalent with the block's default ease and labelled from your garment. length and sleeve_length set the garment and sleeve length. A garment value contradicting a stated body measurement, ease or length is refused with 422."
          },
          "units": {
            "type": "string",
            "enum": [
              "cm",
              "in"
            ]
          },
          "options": {
            "$ref": "#/components/schemas/Options"
          },
          "preferred_color": {
            "type": "string",
            "description": "#RRGGBB, locks the main colour"
          },
          "locked_colors": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "occasion": {
            "type": "string",
            "maxLength": 80
          },
          "template_hint": {
            "type": "string",
            "description": "A template id; a hint only"
          },
          "note": {
            "type": "string",
            "maxLength": 400
          }
        },
        "description": "What the customer states. All optional; everything here is confirmed (their word)."
      },
      "Edits": {
        "type": "object",
        "properties": {
          "template_id": {
            "type": "string"
          },
          "features": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "feature id -> value; an empty string resets to the observation"
          },
          "facts": {
            "$ref": "#/components/schemas/Facts"
          },
          "palette_index": {
            "type": "integer",
            "minimum": 0
          },
          "color_overrides": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "role -> #RRGGBB on the selected palette"
          },
          "lock_main": {
            "type": "boolean"
          }
        },
        "description": "Corrections after the report. Free: no model call, only deterministic recomputation."
      },
      "Photo": {
        "type": "object",
        "properties": {
          "index": {
            "type": "integer"
          },
          "role": {
            "type": "string",
            "enum": [
              "front",
              "back",
              "side",
              "detail",
              "flat"
            ]
          },
          "width": {
            "type": "integer"
          },
          "height": {
            "type": "integer"
          },
          "quality": {
            "type": "integer"
          },
          "usable": {
            "type": "boolean"
          },
          "tips": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "garment_share": {
            "type": "number"
          },
          "skin_share": {
            "type": "number"
          },
          "sharpness": {
            "type": "number"
          },
          "palette": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Up to 5 measured hex colours (approximate image colours)."
          },
          "cut_off": {
            "type": "string",
            "enum": [
              "",
              "top",
              "bottom",
              "both"
            ],
            "description": "Which frame edge the garment runs into (a local heuristic: the garment is cropped, so the hem or the neckline may be out of frame)."
          }
        }
      },
      "PreviewView": {
        "type": "object",
        "properties": {
          "photos": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Photo"
            }
          },
          "usable": {
            "type": "boolean"
          }
        },
        "required": [
          "photos",
          "usable"
        ]
      },
      "Feature": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "value": {
            "type": "string"
          },
          "display": {
            "type": "string"
          },
          "label": {
            "type": "string",
            "enum": [
              "observed",
              "inferred",
              "confirmed",
              "template_default",
              "not_verifiable"
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "observed",
              "inferred",
              "unknown"
            ]
          },
          "confidence": {
            "type": "string"
          },
          "views": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          },
          "uncertain": {
            "type": "boolean"
          },
          "editable": {
            "type": "boolean"
          },
          "note": {
            "type": "string"
          }
        }
      },
      "Palette": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "colors": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "reason": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "model",
              "fallback",
              "original",
              "customer"
            ]
          },
          "locked": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "contrast": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "a": {
                  "type": "string"
                },
                "b": {
                  "type": "string"
                },
                "ratio": {
                  "type": "number"
                }
              }
            }
          }
        },
        "description": "Approximate image colours, not dye lots."
      },
      "Measurement": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "mm": {
            "type": "number"
          },
          "label": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "needed": {
            "type": "boolean"
          },
          "note": {
            "type": "string",
            "description": "On a standard-size value: Standard reference size, not your measurements."
          }
        },
        "description": "One body measurement with its provenance: source is customer, chart:<id> (a chart you confirmed), garment:<key> or standard:<chart>:<size> (the labelled standard reference size, label template_default)."
      },
      "StandardSize": {
        "type": "object",
        "properties": {
          "chart_id": {
            "type": "string"
          },
          "size": {
            "type": "string"
          },
          "label": {
            "type": "string",
            "description": "For example EU 40."
          },
          "chart_version": {
            "type": "string"
          },
          "keys": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The measurements taken from the standard size, in display order."
          }
        },
        "description": "The deterministic standard reference size a draft used because a required value was neither typed, nor from a chart you confirmed, nor from a garment you measured. Never chosen by the model and never inferred from a photo."
      },
      "Need": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "why": {
            "type": "string"
          }
        }
      },
      "Spec": {
        "type": "object",
        "properties": {
          "family": {
            "type": "string",
            "enum": [
              "skirt",
              "trouser",
              "top",
              "dress",
              "coat",
              "other"
            ]
          },
          "template_id": {
            "type": "string"
          },
          "template_version": {
            "type": "string"
          },
          "supported": {
            "type": "boolean"
          },
          "size": {
            "$ref": "#/components/schemas/SizeInput"
          },
          "chart_version": {
            "type": "string"
          },
          "measurements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Measurement"
            }
          },
          "options": {
            "$ref": "#/components/schemas/Options"
          },
          "option_labels": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "option_sources": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Options taken from a garment you measured: option key to garment:<key> (comma separated when several). Absent when none."
          },
          "units": {
            "type": "string"
          },
          "palette_index": {
            "type": "integer"
          },
          "colors": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "standard_size": {
            "$ref": "#/components/schemas/StandardSize"
          },
          "approximate": {
            "type": "boolean",
            "description": "True when features no reviewed block drafts were seen and template_id is the closest basic block."
          },
          "closest_of": {
            "type": "string",
            "description": "Which block stands in for the garment and how, when approximate."
          }
        }
      },
      "OutputState": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "available",
              "concept_available",
              "blocked"
            ]
          },
          "views": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "count": {
            "type": "integer"
          },
          "export_allowed": {
            "type": "boolean"
          },
          "reason": {
            "type": "string"
          }
        }
      },
      "Outputs": {
        "type": "object",
        "properties": {
          "sketch": {
            "$ref": "#/components/schemas/OutputState"
          },
          "flats": {
            "$ref": "#/components/schemas/OutputState"
          },
          "patterns": {
            "$ref": "#/components/schemas/OutputState"
          },
          "palettes": {
            "$ref": "#/components/schemas/OutputState"
          }
        }
      },
      "Piece": {
        "type": "object",
        "properties": {
          "piece_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "cut_qty": {
            "type": "integer"
          },
          "material": {
            "type": "string"
          },
          "mirror": {
            "type": "boolean"
          },
          "on_fold": {
            "type": "boolean"
          },
          "width_mm": {
            "type": "number"
          },
          "height_mm": {
            "type": "number"
          },
          "cut_from": {
            "type": "string",
            "description": "The id of the piece this lining copy repeats. It is drawn in the pattern SVG but not printed again in the PDF."
          }
        }
      },
      "Validation": {
        "type": "object",
        "properties": {
          "passed": {
            "type": "boolean"
          },
          "issues": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "checks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Check"
            }
          }
        }
      },
      "Garment": {
        "type": "object",
        "properties": {
          "family": {
            "type": "string",
            "enum": [
              "skirt",
              "trouser",
              "top",
              "dress",
              "coat",
              "other"
            ]
          },
          "family_name": {
            "type": "string"
          },
          "template_id": {
            "type": "string"
          },
          "supported": {
            "type": "boolean"
          },
          "confidence": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "silhouette": {
            "type": "string"
          }
        }
      },
      "Report": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string"
          },
          "revision": {
            "type": "integer"
          },
          "garment": {
            "$ref": "#/components/schemas/Garment"
          },
          "photos": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Photo"
            }
          },
          "features": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Feature"
            }
          },
          "measured_colors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "hex": {
                  "type": "string"
                },
                "share": {
                  "type": "number"
                }
              }
            }
          },
          "palettes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Palette"
            }
          },
          "spec": {
            "$ref": "#/components/schemas/Spec"
          },
          "status": {
            "type": "string",
            "enum": [
              "measured_draft",
              "standard_draft",
              "approximate_draft",
              "needs_measurements",
              "conceptual",
              "blocked"
            ]
          },
          "outputs": {
            "$ref": "#/components/schemas/Outputs"
          },
          "pieces": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Piece"
            }
          },
          "needs_confirmation": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Need"
            }
          },
          "unsupported_features": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "validation": {
            "$ref": "#/components/schemas/Validation"
          },
          "stated": {
            "$ref": "#/components/schemas/Facts"
          },
          "checks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Check"
            }
          },
          "checks_passed": {
            "type": "boolean"
          },
          "summary": {
            "type": "string"
          },
          "summary_by_ai": {
            "type": "boolean"
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "limits": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The four things a report never says, always in this order."
          },
          "guarantee": {
            "type": "null",
            "description": "Always null: no guarantee is made."
          },
          "fit_proven": {
            "type": "boolean",
            "description": "Always false."
          },
          "recommended_next_step": {
            "type": "string"
          },
          "edits": {
            "type": "integer"
          },
          "prompt": {
            "type": "string"
          },
          "prompt_fingerprint": {
            "type": "string"
          },
          "visibility": {
            "$ref": "#/components/schemas/Visibility"
          }
        },
        "required": [
          "version",
          "garment",
          "status",
          "limits",
          "guarantee",
          "fit_proven"
        ],
        "description": "The delivered report. Every fact carries one of five labels: observed, inferred, confirmed, template_default or not_verifiable."
      },
      "AnalysisSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "error": {
            "type": "string"
          },
          "family": {
            "type": "string",
            "enum": [
              "skirt",
              "trouser",
              "top",
              "dress",
              "coat",
              "other"
            ]
          },
          "family_name": {
            "type": "string"
          },
          "template_id": {
            "type": "string"
          },
          "template_name": {
            "type": "string"
          },
          "supported": {
            "type": "boolean"
          },
          "report_status": {
            "type": "string",
            "enum": [
              "measured_draft",
              "standard_draft",
              "approximate_draft",
              "needs_measurements",
              "conceptual",
              "blocked"
            ]
          },
          "status_label": {
            "type": "string"
          },
          "silhouette": {
            "type": "string"
          },
          "silhouette_label": {
            "type": "string"
          },
          "main_color": {
            "type": "string"
          },
          "palette_count": {
            "type": "integer"
          },
          "pieces": {
            "type": "integer"
          },
          "validation_passed": {
            "type": "boolean"
          },
          "checks_passed": {
            "type": "boolean"
          },
          "needs": {
            "type": "integer"
          },
          "edits": {
            "type": "integer"
          },
          "photos": {
            "type": "integer"
          },
          "quality": {
            "type": "integer"
          },
          "project_id": {
            "type": "string"
          },
          "project_name": {
            "type": "string"
          },
          "units": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "status",
          "created_at"
        ]
      },
      "AnalysisView": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "project_id": {
            "type": "string"
          },
          "project_name": {
            "type": "string"
          },
          "report": {
            "$ref": "#/components/schemas/Report"
          },
          "has_thumbnail": {
            "type": "boolean"
          },
          "units": {
            "type": "integer"
          },
          "cost_eur": {
            "type": "number"
          },
          "source": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "created_at",
          "report"
        ]
      },
      "MetaView": {
        "type": "object",
        "properties": {
          "families": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Option"
            }
          },
          "templates": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "roles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Option"
            }
          },
          "features": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "measurements": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "standard_sizes": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "The standard reference sizes (XS 34, S 36, M 40, L 44, XL 48, 2XL 52 of the women's chart): name, size, label, default, measures_mm. Pick one with facts.size = {system: eu, value: <size>, chart_id: tl-eu-w-1} without confirming the chart."
          },
          "unsupported_features": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Option"
            },
            "description": "The features no reviewed block drafts (ids as in a report's unsupported_features)."
          },
          "garment_measurements": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "The optional finished-garment measures with how to take each: key, name, help, min_mm, max_mm, kind, body, families."
          },
          "charts": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "labels": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Option"
            }
          },
          "palette_roles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Option"
            }
          },
          "fits": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Option"
            }
          },
          "units": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Option"
            }
          },
          "limits": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "statuses": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "export_formats": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "papers": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "photos": {
            "type": "object"
          },
          "facts": {
            "type": "object"
          }
        }
      },
      "Visibility": {
        "type": "object",
        "description": "How much of the garment the photos show. A cut-off hem (or the waist of a skirt or trousers) blocks the pattern until the length is typed or a full photo is analysed.",
        "properties": {
          "extent": {
            "type": "string",
            "enum": [
              "full",
              "upper_body",
              "lower_body",
              "partial"
            ]
          },
          "hem_visible": {
            "type": "boolean"
          },
          "top_visible": {
            "type": "boolean"
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "model",
                "frame"
              ]
            },
            "description": "Who says the garment is cut off: the reader (model) or the frame heuristic."
          },
          "length_stated": {
            "type": "boolean",
            "description": "The customer typed or measured the garment length."
          }
        }
      }
    }
  }
}
