{
  "openapi": "3.1.1",
  "info": {
    "title": "Living Hinge Pattern Generator (laser flex) API",
    "version": "1.0.0",
    "summary": "Laser-cut living hinge (flex) patterns sized from the bend angle and radius — SVG, DXF and PDF.",
    "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://kerfwiselivinghinge.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Laser-cut living hinge (flex) patterns sized from the bend angle and radius — SVG, DXF and PDF.",
        "description": "Generate a living hinge (kerf bending, flex pattern) for plywood, MDF or acrylic: straight, wave or zigzag rows of staggered cuts across a bend zone. The zone length follows from the bend angle and the inside radius on the neutral axis; you also get the number of rows, the twist each strip has to take, the size of the torsion links and the total cut length.\n\nMethodology:\n- Bend length on the neutral axis = bend angle (radians) × (inside radius + thickness ÷ 2). The zone gets round(length ÷ row spacing) + 1 rows, so the zone is (rows − 1) × spacing and sits in the middle of the panel.\n- Each row has cuts of the given length separated by bridges; neighbouring rows are shifted by half a period, so the material between two rows forms torsion links of length (cut − bridge) ÷ 2 and width row spacing − kerf. Every link row takes bend angle ÷ (rows − 1) of twist.\n- Cuts keep one bridge length from the top and bottom edges. Wave and zigzag rows follow the same function, so neighbouring rows never touch. Only the outline is kerf-compensated; the hinge cuts stay on their lines. SVG files use millimetres (width/height in mm, 1 user unit = 1 mm) with one group per layer: cut (red #e4002b), score (blue #0067c5), engrave (black) and labels (grey). DXF R12 uses the same layers, millimetres, y up.\n\nHow far a hinge bends depends on the material, the grain, the glue in plywood and the laser settings — cut a short sample first. Laser cutters and CNC routers can start fires and release harmful fumes: never leave the machine unattended, use extraction, and never cut PVC, vinyl or other chlorine-containing plastics. Sizes, kerf and fit are starting points — check them with a test cut and follow your machine maker's safety rules.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "kerfwise_living_hinge",
        "x-owner-app": "kerfwise",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KerfwiseLivingHingeInput"
              },
              "examples": {
                "example1": {
                  "summary": "90° corner with 15 mm radius in 3 mm plywood",
                  "value": {
                    "width": 140,
                    "height": 60,
                    "thickness": 3,
                    "angle": 90,
                    "radius": 15
                  }
                },
                "example2": {
                  "summary": "Wave pattern, 180° bend around 20 mm",
                  "value": {
                    "width": 200,
                    "height": 80,
                    "thickness": 3,
                    "pattern": "wave",
                    "angle": 180,
                    "radius": 20,
                    "pitch": 2
                  }
                },
                "example3": {
                  "summary": "Zigzag strip with a fixed 50 mm zone",
                  "value": {
                    "width": 120,
                    "height": 40,
                    "thickness": 2,
                    "pattern": "zigzag",
                    "zone": 50,
                    "cut": 14,
                    "bridge": 2.5
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KerfwiseLivingHingeResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "KerfwiseLivingHingeInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "width": {
            "title": "Panel width across the bend (mm)",
            "type": "number",
            "minimum": 20,
            "maximum": 2000,
            "default": 140
          },
          "height": {
            "title": "Panel height along the bend axis (mm)",
            "type": "number",
            "minimum": 10,
            "maximum": 2000,
            "default": 60
          },
          "thickness": {
            "title": "Material thickness (mm)",
            "type": "number",
            "minimum": 0.5,
            "maximum": 20,
            "default": 3
          },
          "pattern": {
            "title": "Cut pattern",
            "type": "string",
            "enum": [
              "straight",
              "wave",
              "zigzag"
            ],
            "default": "straight"
          },
          "cut": {
            "title": "Cut length (mm)",
            "type": "number",
            "minimum": 2,
            "maximum": 500,
            "default": 18
          },
          "bridge": {
            "title": "Bridge between cuts (mm)",
            "type": "number",
            "minimum": 0.5,
            "maximum": 100,
            "default": 3
          },
          "pitch": {
            "title": "Row spacing (mm)",
            "type": "number",
            "minimum": 0.5,
            "maximum": 50,
            "default": 1.6
          },
          "angle": {
            "title": "Bend angle (degrees)",
            "type": "number",
            "minimum": 1,
            "maximum": 360,
            "default": 90
          },
          "radius": {
            "title": "Inside bend radius (mm)",
            "type": "number",
            "minimum": 0,
            "maximum": 1000,
            "default": 15
          },
          "zone": {
            "title": "Bend zone length (mm, 0 = from angle and radius)",
            "type": "number",
            "minimum": 0,
            "maximum": 2000,
            "default": 0
          },
          "kerf": {
            "title": "Kerf compensation for the outline (mm)",
            "type": "number",
            "minimum": 0,
            "maximum": 3,
            "default": 0.15
          },
          "sheetWidth": {
            "title": "Sheet or laser bed width (mm, 0 = no sheet)",
            "description": "With a sheet size the parts are nested onto as many sheets as needed; 0 lays every part out in one drawing.",
            "type": "number",
            "minimum": 0,
            "maximum": 5000,
            "default": 0
          },
          "sheetHeight": {
            "title": "Sheet or laser bed height (mm, 0 = no sheet)",
            "type": "number",
            "minimum": 0,
            "maximum": 5000,
            "default": 0
          },
          "spacing": {
            "title": "Gap between parts (mm)",
            "description": "For CNC routing use at least the cutter diameter.",
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "default": 4
          },
          "labels": {
            "title": "Part names on a separate label layer",
            "type": "boolean",
            "default": true
          },
          "paper": {
            "title": "PDF pages",
            "type": "string",
            "enum": [
              "fit",
              "a3",
              "a4",
              "a5",
              "a6",
              "b5",
              "letter",
              "legal",
              "tabloid",
              "halfletter"
            ],
            "default": "fit"
          }
        },
        "required": []
      },
      "KerfwiseLivingHingeResult": {
        "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": [
              "arcLength",
              "zone",
              "zoneStart",
              "rows",
              "twistPerRow",
              "linkLength",
              "linkWidth",
              "cutLength",
              "sheets",
              "parts",
              "pdfPages",
              "warnings",
              "files",
              "openInApp"
            ],
            "properties": {
              "arcLength": {
                "type": "number"
              },
              "zone": {
                "type": "number"
              },
              "zoneStart": {
                "type": "number"
              },
              "rows": {
                "type": "integer"
              },
              "twistPerRow": {
                "type": "number"
              },
              "linkLength": {
                "type": "number"
              },
              "linkWidth": {
                "type": "number"
              },
              "cutLength": {
                "type": "number"
              },
              "sheets": {
                "type": "integer"
              },
              "parts": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "label",
                    "name",
                    "width",
                    "height",
                    "sheet"
                  ],
                  "properties": {
                    "label": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "width": {
                      "type": "number"
                    },
                    "height": {
                      "type": "number"
                    },
                    "sheet": {
                      "type": "integer"
                    }
                  }
                }
              },
              "pdfPages": {
                "type": "integer"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "files": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "pdf"
                ],
                "properties": {
                  "pdf": {
                    "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"
              }
            }
          }
        }
      }
    }
  }
}