{
  "openapi": "3.1.1",
  "info": {
    "title": "3D Form Model Report & Export API",
    "version": "1.0.0",
    "summary": "Measure a form model by tag and export its geometry as OBJ or STL.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://kerfwisemodelreport.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Measure a form model by tag and export its geometry as OBJ or STL.",
        "description": "Inspect a Kerfwise Form Studio project for object bounds, gross surface area, volume and triangle counts. Group quantities by tag and download the normalized project, OBJ and STL files.\n\nMethodology:\n- All geometry is in millimetres, with Z up. Accept one simple, non-self-intersecting footprint without holes, 3–64 vertices and at least 1 mm² area. Extrude vertically, then rotate around Z and translate.\n- Triangulate both caps and each side with consistent outward winding. Each separate prism is closed; intersecting prisms are not unioned. Surface = 2 × footprint area + perimeter × height; gross volume = footprint area × height.\n- Models contain at most 128 solids and eight saved camera views. Coordinates, heights and profiles are bounded. OBJ and ASCII STL use millimetres; STL does not embed a unit. These are concept models, separate from cabinet cut lists or machining instructions.\n- Visible-only export is on by default. Hidden solids can be included explicitly. Report bounds are axis-aligned after rotation; quantities sum complete solids, so touching internal faces and overlapping volumes remain counted.\n\nGross quantities count complete solids, including overlaps and internal faces. STL is unitless; import it as millimetres.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "kerfwise_model_report",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KerfwiseModelReportInput"
              },
              "examples": {
                "example1": {
                  "summary": "L-shaped concept model",
                  "value": {
                    "project": "{\"format\":\"kerfwise-form\",\"version\":1,\"name\":\"L-shaped counter\",\"units\":\"mm\",\"grid\":100,\"snap\":true,\"objects\":[{\"id\":\"counter\",\"name\":\"Counter volume\",\"tag\":\"Concepts\",\"color\":\"#bda483\",\"profile\":[[0,0],[2800,0],[2800,650],[900,650],[900,2200],[0,2200]],\"height\":900,\"x\":-1400,\"y\":-1100,\"z\":0,\"rotation\":0,\"visible\":true,\"locked\":false}],\"scenes\":[{\"name\":\"Overview\",\"camera\":{\"azimuth\":-45,\"elevation\":32,\"target\":[0,0,450],\"span\":4223.8045646076}},{\"name\":\"Plan view\",\"camera\":{\"azimuth\":-90,\"elevation\":90,\"target\":[0,0,450],\"span\":4223.8045646076}}]}",
                    "visibleOnly": true
                  }
                },
                "example2": {
                  "summary": "Tagged pavilion quantities",
                  "value": {
                    "project": "{\"format\":\"kerfwise-form\",\"version\":1,\"name\":\"Courtyard pavilion\",\"units\":\"mm\",\"grid\":100,\"snap\":true,\"objects\":[{\"id\":\"part-1\",\"name\":\"Platform\",\"tag\":\"Architecture\",\"color\":\"#d2c6b5\",\"profile\":[[0,0],[5000,0],[5000,3600],[0,3600]],\"height\":150,\"x\":-2500,\"y\":-1800,\"z\":0,\"rotation\":0,\"visible\":true,\"locked\":false},{\"id\":\"part-2\",\"name\":\"Column\",\"tag\":\"Architecture\",\"color\":\"#73938a\",\"profile\":[[0,0],[200,0],[200,200],[0,200]],\"height\":2700,\"x\":-2200,\"y\":-1500,\"z\":150,\"rotation\":0,\"visible\":true,\"locked\":false},{\"id\":\"part-3\",\"name\":\"Column\",\"tag\":\"Architecture\",\"color\":\"#73938a\",\"profile\":[[0,0],[200,0],[200,200],[0,200]],\"height\":2700,\"x\":-2200,\"y\":1300,\"z\":150,\"rotation\":0,\"visible\":true,\"locked\":false},{\"id\":\"part-4\",\"name\":\"Column\",\"tag\":\"Architecture\",\"color\":\"#73938a\",\"profile\":[[0,0],[200,0],[200,200],[0,200]],\"height\":2700,\"x\":2000,\"y\":-1500,\"z\":150,\"rotation\":0,\"visible\":true,\"locked\":false},{\"id\":\"part-5\",\"name\":\"Column\",\"tag\":\"Architecture\",\"color\":\"#73938a\",\"profile\":[[0,0],[200,0],[200,200],[0,200]],\"height\":2700,\"x\":2000,\"y\":1300,\"z\":150,\"rotation\":0,\"visible\":true,\"locked\":false},{\"id\":\"part-6\",\"name\":\"Canopy\",\"tag\":\"Architecture\",\"color\":\"#b58f62\",\"profile\":[[0,0],[5400,0],[5400,4000],[0,4000]],\"height\":180,\"x\":-2700,\"y\":-2000,\"z\":2850,\"rotation\":0,\"visible\":true,\"locked\":false},{\"id\":\"part-7\",\"name\":\"Bench\",\"tag\":\"Furniture\",\"color\":\"#c7ac86\",\"profile\":[[0,0],[2800,0],[2800,500],[0,500]],\"height\":450,\"x\":-1400,\"y\":700,\"z\":150,\"rotation\":0,\"visible\":true,\"locked\":false}],\"scenes\":[{\"name\":\"Overview\",\"camera\":{\"azimuth\":-45,\"elevation\":32,\"target\":[0,0,1515],\"span\":8477.372249111158}},{\"name\":\"Plan view\",\"camera\":{\"azimuth\":-90,\"elevation\":90,\"target\":[0,0,1515],\"span\":8477.372249111158}}]}",
                    "visibleOnly": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KerfwiseModelReportResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "KerfwiseModelReportInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "project": {
            "title": "Form Studio project JSON",
            "type": "string",
            "maxLength": 2000000,
            "default": "{\n  \"format\": \"kerfwise-form\",\n  \"version\": 1,\n  \"name\": \"L-shaped counter\",\n  \"units\": \"mm\",\n  \"grid\": 100,\n  \"snap\": true,\n  \"objects\": [\n    {\n      \"id\": \"counter\",\n      \"name\": \"Counter volume\",\n      \"tag\": \"Concepts\",\n      \"color\": \"#bda483\",\n      \"profile\": [\n        [\n          0,\n          0\n        ],\n        [\n          2800,\n          0\n        ],\n        [\n          2800,\n          650\n        ],\n        [\n          900,\n          650\n        ],\n        [\n          900,\n          2200\n        ],\n        [\n          0,\n          2200\n        ]\n      ],\n      \"height\": 900,\n      \"x\": -1400,\n      \"y\": -1100,\n      \"z\": 0,\n      \"rotation\": 0,\n      \"visible\": true,\n      \"locked\": false\n    }\n  ],\n  \"scenes\": [\n    {\n      \"name\": \"Overview\",\n      \"camera\": {\n        \"azimuth\": -45,\n        \"elevation\": 32,\n        \"target\": [\n          0,\n          0,\n          450\n        ],\n        \"span\": 4223.8045646076\n      }\n    },\n    {\n      \"name\": \"Plan view\",\n      \"camera\": {\n        \"azimuth\": -90,\n        \"elevation\": 90,\n        \"target\": [\n          0,\n          0,\n          450\n        ],\n        \"span\": 4223.8045646076\n      }\n    }\n  ]\n}"
          },
          "visibleOnly": {
            "title": "Report and export visible solids only",
            "type": "boolean",
            "default": true
          }
        },
        "required": []
      },
      "KerfwiseModelReportResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "project",
              "report",
              "exports",
              "openInApp"
            ],
            "properties": {
              "project": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "format",
                  "version",
                  "name",
                  "units",
                  "grid",
                  "snap",
                  "objects",
                  "scenes"
                ],
                "properties": {
                  "format": {
                    "const": "kerfwise-form"
                  },
                  "version": {
                    "const": 1
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "units": {
                    "enum": [
                      "mm",
                      "in"
                    ]
                  },
                  "grid": {
                    "type": "number",
                    "minimum": 0.1,
                    "maximum": 10000
                  },
                  "snap": {
                    "type": "boolean"
                  },
                  "objects": {
                    "type": "array",
                    "maxItems": 128,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "id",
                        "name",
                        "tag",
                        "color",
                        "profile",
                        "height",
                        "x",
                        "y",
                        "z",
                        "rotation",
                        "visible",
                        "locked"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "pattern": "^[-a-zA-Z0-9_]{1,64}$"
                        },
                        "name": {
                          "type": "string",
                          "maxLength": 80
                        },
                        "tag": {
                          "type": "string",
                          "maxLength": 40
                        },
                        "color": {
                          "type": "string",
                          "pattern": "^#[a-fA-F0-9]{6}$"
                        },
                        "profile": {
                          "type": "array",
                          "minItems": 3,
                          "maxItems": 64,
                          "items": {
                            "type": "array",
                            "minItems": 2,
                            "maxItems": 2,
                            "items": {
                              "type": "number",
                              "minimum": -100000,
                              "maximum": 100000
                            }
                          }
                        },
                        "height": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100000
                        },
                        "x": {
                          "type": "number",
                          "minimum": -100000,
                          "maximum": 100000
                        },
                        "y": {
                          "type": "number",
                          "minimum": -100000,
                          "maximum": 100000
                        },
                        "z": {
                          "type": "number",
                          "minimum": -100000,
                          "maximum": 100000
                        },
                        "rotation": {
                          "type": "number"
                        },
                        "visible": {
                          "type": "boolean"
                        },
                        "locked": {
                          "type": "boolean"
                        }
                      }
                    }
                  },
                  "scenes": {
                    "type": "array",
                    "maxItems": 8,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "name",
                        "camera"
                      ],
                      "properties": {
                        "name": {
                          "type": "string",
                          "maxLength": 60
                        },
                        "camera": {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "azimuth",
                            "elevation",
                            "span",
                            "target"
                          ],
                          "properties": {
                            "azimuth": {
                              "type": "number"
                            },
                            "elevation": {
                              "type": "number",
                              "minimum": 5,
                              "maximum": 90
                            },
                            "span": {
                              "type": "number",
                              "minimum": 10,
                              "maximum": 1000000
                            },
                            "target": {
                              "type": "array",
                              "minItems": 3,
                              "maxItems": 3,
                              "items": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              },
              "report": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "count",
                  "surfaceM2",
                  "volumeM3",
                  "triangles",
                  "bounds",
                  "objects",
                  "tags"
                ],
                "properties": {
                  "count": {
                    "type": "integer"
                  },
                  "surfaceM2": {
                    "type": "number"
                  },
                  "volumeM3": {
                    "type": "number"
                  },
                  "triangles": {
                    "type": "integer"
                  },
                  "bounds": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "min",
                      "max",
                      "size"
                    ],
                    "properties": {
                      "min": {
                        "type": "array",
                        "minItems": 3,
                        "maxItems": 3,
                        "items": {
                          "type": "number"
                        }
                      },
                      "max": {
                        "type": "array",
                        "minItems": 3,
                        "maxItems": 3,
                        "items": {
                          "type": "number"
                        }
                      },
                      "size": {
                        "type": "array",
                        "minItems": 3,
                        "maxItems": 3,
                        "items": {
                          "type": "number"
                        }
                      }
                    }
                  },
                  "objects": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "id",
                        "name",
                        "tag",
                        "footprintM2",
                        "surfaceM2",
                        "volumeM3",
                        "triangles",
                        "bounds"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "tag": {
                          "type": "string"
                        },
                        "footprintM2": {
                          "type": "number"
                        },
                        "surfaceM2": {
                          "type": "number"
                        },
                        "volumeM3": {
                          "type": "number"
                        },
                        "triangles": {
                          "type": "integer"
                        },
                        "bounds": {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "min",
                            "max",
                            "size"
                          ],
                          "properties": {
                            "min": {
                              "type": "array",
                              "minItems": 3,
                              "maxItems": 3,
                              "items": {
                                "type": "number"
                              }
                            },
                            "max": {
                              "type": "array",
                              "minItems": 3,
                              "maxItems": 3,
                              "items": {
                                "type": "number"
                              }
                            },
                            "size": {
                              "type": "array",
                              "minItems": 3,
                              "maxItems": 3,
                              "items": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    }
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "tag",
                        "count",
                        "surfaceM2",
                        "volumeM3"
                      ],
                      "properties": {
                        "tag": {
                          "type": "string"
                        },
                        "count": {
                          "type": "integer"
                        },
                        "surfaceM2": {
                          "type": "number"
                        },
                        "volumeM3": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              },
              "exports": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "obj",
                  "stl",
                  "project"
                ],
                "properties": {
                  "obj": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "artifactId",
                      "filename",
                      "mime",
                      "bytes",
                      "sha256",
                      "path"
                    ],
                    "properties": {
                      "artifactId": {
                        "type": "string"
                      },
                      "filename": {
                        "type": "string"
                      },
                      "mime": {
                        "type": "string"
                      },
                      "bytes": {
                        "type": "integer"
                      },
                      "sha256": {
                        "type": "string"
                      },
                      "path": {
                        "type": "string",
                        "description": "Download path on the same site (valid for about 2 hours)."
                      }
                    }
                  },
                  "stl": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "artifactId",
                      "filename",
                      "mime",
                      "bytes",
                      "sha256",
                      "path"
                    ],
                    "properties": {
                      "artifactId": {
                        "type": "string"
                      },
                      "filename": {
                        "type": "string"
                      },
                      "mime": {
                        "type": "string"
                      },
                      "bytes": {
                        "type": "integer"
                      },
                      "sha256": {
                        "type": "string"
                      },
                      "path": {
                        "type": "string",
                        "description": "Download path on the same site (valid for about 2 hours)."
                      }
                    }
                  },
                  "project": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "artifactId",
                      "filename",
                      "mime",
                      "bytes",
                      "sha256",
                      "path"
                    ],
                    "properties": {
                      "artifactId": {
                        "type": "string"
                      },
                      "filename": {
                        "type": "string"
                      },
                      "mime": {
                        "type": "string"
                      },
                      "bytes": {
                        "type": "integer"
                      },
                      "sha256": {
                        "type": "string"
                      },
                      "path": {
                        "type": "string",
                        "description": "Download path on the same site (valid for about 2 hours)."
                      }
                    }
                  }
                }
              },
              "openInApp": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}