{
  "openapi": "3.1.1",
  "info": {
    "title": "Footprint to 3D Solid Extruder API",
    "version": "1.0.0",
    "summary": "Turn a simple footprint into a closed 3D solid with OBJ, STL and editable geometry.",
    "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://kerfwiseprofileextruder.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Turn a simple footprint into a closed 3D solid with OBJ, STL and editable geometry.",
        "description": "Enter a polygon footprint and extrusion height to make a closed 3D prism. Set its placement and rotation, measure surface and volume, and open the editable result in Kerfwise Form Studio.\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\nConcept geometry only. Separate shells are not fused; gross quantities include overlaps. Not cabinet manufacturing output.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "kerfwise_profile_extruder",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KerfwiseProfileExtruderInput"
              },
              "examples": {
                "example1": {
                  "summary": "An L-shaped extrusion",
                  "value": {
                    "points": "0,0\n1200,0\n1200,400\n500,400\n500,1000\n0,1000",
                    "height": 600
                  }
                },
                "example2": {
                  "summary": "Raised rectangular plinth",
                  "value": {
                    "points": "0,0;800,0;800,500;0,500",
                    "height": 180,
                    "z": 100,
                    "rotation": 30
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KerfwiseProfileExtruderResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "KerfwiseProfileExtruderInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "points": {
            "title": "Footprint X,Y pairs in mm (one per line)",
            "type": "string",
            "maxLength": 12000,
            "default": "0,0\n1200,0\n1200,400\n500,400\n500,1000\n0,1000"
          },
          "height": {
            "title": "Extrusion height (mm)",
            "type": "number",
            "minimum": 1,
            "maximum": 100000,
            "default": 600
          },
          "x": {
            "title": "Origin X (mm)",
            "type": "number",
            "minimum": -100000,
            "maximum": 100000,
            "default": 0
          },
          "y": {
            "title": "Origin Y (mm)",
            "type": "number",
            "minimum": -100000,
            "maximum": 100000,
            "default": 0
          },
          "z": {
            "title": "Base elevation (mm)",
            "type": "number",
            "minimum": -100000,
            "maximum": 100000,
            "default": 0
          },
          "rotation": {
            "title": "Rotation around Z (degrees)",
            "type": "number",
            "minimum": -36000,
            "maximum": 36000,
            "default": 0
          },
          "name": {
            "title": "Solid name",
            "type": "string",
            "maxLength": 80,
            "default": "L-shaped solid"
          },
          "color": {
            "title": "Solid color (HEX)",
            "type": "string",
            "maxLength": 7,
            "default": "#b9c9b4"
          }
        },
        "required": []
      },
      "KerfwiseProfileExtruderResult": {
        "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",
              "mesh",
              "surfaceM2",
              "volumeM3",
              "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"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              },
              "mesh": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "vertices",
                  "triangles"
                ],
                "properties": {
                  "vertices": {
                    "type": "array",
                    "items": {
                      "type": "array",
                      "minItems": 3,
                      "maxItems": 3,
                      "items": {
                        "type": "number"
                      }
                    }
                  },
                  "triangles": {
                    "type": "array",
                    "items": {
                      "type": "array",
                      "minItems": 3,
                      "maxItems": 3,
                      "items": {
                        "type": "integer"
                      }
                    }
                  }
                }
              },
              "surfaceM2": {
                "type": "number"
              },
              "volumeM3": {
                "type": "number"
              },
              "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"
              }
            }
          }
        }
      }
    }
  }
}