{"openapi":"3.1.0","info":{"title":"Cubefit API","version":"1.0.0","description":"Server-side pallet packing. Pack one carton SKU onto a pallet; list pallet presets. Request bodies are generated from the live Zod schemas.","contact":{"name":"CLICKAPLY","url":"https://www.clickaply.com/contact"}},"servers":[{"url":"https://cubefit.app","description":"Production"},{"url":"http://127.0.0.1:43129","description":"Local preview"}],"security":[{"bearerAuth":[]}],"paths":{"/api/v1/pack":{"post":{"operationId":"packPallet","summary":"Pack a carton onto a pallet","description":"Runs the Cubefit packing engine. Default response omits placements and geometry unless requested via `include`.","tags":["Pack"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PackRequest"},"example":{"pallet":{"length":1200,"width":800,"deckHeight":144,"preset":"euro"},"box":{"length":400,"width":300,"height":200,"qtyPerBox":12},"targetHeight":1800,"allowRotate":false,"unit":"mm","mode":"pallet"}}}},"responses":{"200":{"description":"Pack result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PackResponse"},"example":{"orientation":{"id":"pack","length":400,"width":300,"height":200,"tipped":false},"layer":{"boxesPerLayer":8,"placements":[],"usedArea":960000,"wasteArea":20100,"fillPercent":97.9},"layerCount":8,"totalBoxes":64,"productQty":768,"heightUsed":1744,"targetHeight":1800,"heightRemainingMm":56,"nextLayerOverrunMm":144,"unusedFootprintMm2":20100,"fillPercent":97.9,"weightTotalKg":null,"warnings":[{"code":"HEIGHT_SPACE_LEFT","message":"HEIGHT_SPACE_LEFT"}],"layerStrategy":"uniform","alternateLayers":false,"fullLayerCount":8,"topLayerBoxCount":8}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Origin or scope denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/presets":{"get":{"operationId":"listPalletPresets","summary":"List pallet presets","description":"Euro, UK, GMA, CHEP, ISO and related presets with deck height and tare.","tags":["Presets"],"responses":{"200":{"description":"Preset list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PresetsResponse"},"example":{"object":"list","data":[{"id":"euro","label":"Euro / EPAL 1200×800","length":1200,"width":800,"deckHeight":144,"emptyWeightKg":25,"group":"common"}]}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"pk_… or sk_…","description":"Publishable keys (pk_) require an exact Origin allowlist match and are pack-scoped. Secret keys (sk_) are for servers and MCP; do not send a browser Origin with sk_."}},"schemas":{"PackRequest":{"type":"object","properties":{"pallet":{"type":"object","properties":{"length":{"type":"number","exclusiveMinimum":0,"maximum":20000},"width":{"type":"number","exclusiveMinimum":0,"maximum":20000},"deckHeight":{"type":"number","minimum":0,"maximum":20000},"preset":{"type":"string","enum":["euro","uk","epal2","epal3","epal6","chep_eur","gma","iso_au","custom"]}},"required":["length","width","deckHeight"],"additionalProperties":false},"box":{"type":"object","properties":{"length":{"type":"number","minimum":10,"maximum":20000},"width":{"type":"number","minimum":10,"maximum":20000},"height":{"type":"number","minimum":10,"maximum":20000},"qtyPerBox":{"type":"number","exclusiveMinimum":0,"maximum":10000},"weightKg":{"type":"number","minimum":0,"maximum":1000000}},"required":["length","width","height","qtyPerBox"],"additionalProperties":false},"targetHeight":{"type":"number","exclusiveMinimum":0,"maximum":5000},"allowRotate":{"default":false,"type":"boolean"},"footprintTolerance":{"type":"number","minimum":0,"maximum":20000},"maxLoadKg":{"type":"number","exclusiveMinimum":0,"maximum":1000000},"emptyPalletWeightKg":{"type":"number","minimum":0,"maximum":1000000},"unit":{"default":"mm","type":"string","enum":["mm","cm","in"]},"allowHeightOverrun":{"type":"boolean"},"allowUnevenLayers":{"type":"boolean"},"mode":{"type":"string","enum":["pallet"]},"include":{"maxItems":2,"type":"array","items":{"type":"string","enum":["placements","geometry"]}}},"required":["pallet","box","targetHeight","allowRotate","unit"],"additionalProperties":false},"PackResponse":{"type":"object","properties":{"orientation":{"type":"object","properties":{"id":{"type":"string"},"length":{"type":"number"},"width":{"type":"number"},"height":{"type":"number"},"tipped":{"type":"boolean"}},"required":["id","length","width","height","tipped"],"additionalProperties":false},"layer":{"type":"object","properties":{"boxesPerLayer":{"type":"number"},"placements":{"type":"array","items":{"type":"object","properties":{"x":{"type":"number"},"y":{"type":"number"},"z":{"type":"number"},"length":{"type":"number"},"width":{"type":"number"},"height":{"type":"number"},"orientationId":{"type":"string"}},"required":["x","y","z","length","width","height","orientationId"],"additionalProperties":false}},"usedArea":{"type":"number"},"wasteArea":{"type":"number"},"fillPercent":{"type":"number"}},"required":["boxesPerLayer","placements","usedArea","wasteArea","fillPercent"],"additionalProperties":false},"layerCount":{"type":"number"},"totalBoxes":{"type":"number"},"productQty":{"type":"number"},"heightUsed":{"type":"number"},"targetHeight":{"type":"number"},"heightRemainingMm":{"type":"number"},"nextLayerOverrunMm":{"type":["number","null"]},"unusedFootprintMm2":{"type":"number"},"fillPercent":{"type":"number"},"weightTotalKg":{"type":["number","null"]},"warnings":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"],"additionalProperties":false}},"layerStrategy":{"type":"string","enum":["uniform","mixed"]},"alternateLayers":{"type":"boolean"},"fullLayerCount":{"type":"number"},"topLayerBoxCount":{"type":"number"},"geometry":{"type":"object","properties":{"pallet":{"type":"object","properties":{"length":{"type":"number"},"width":{"type":"number"},"deckHeight":{"type":"number"}},"required":["length","width","deckHeight"],"additionalProperties":false},"boxes":{"type":"array","items":{"type":"object","properties":{"x":{"type":"number"},"y":{"type":"number"},"z":{"type":"number"},"length":{"type":"number"},"width":{"type":"number"},"height":{"type":"number"},"orientationId":{"type":"string"}},"required":["x","y","z","length","width","height","orientationId"],"additionalProperties":false}}},"required":["pallet","boxes"],"additionalProperties":false}},"required":["orientation","layer","layerCount","totalBoxes","productQty","heightUsed","targetHeight","heightRemainingMm","nextLayerOverrunMm","unusedFootprintMm2","fillPercent","weightTotalKg","warnings","layerStrategy","alternateLayers","fullLayerCount","topLayerBoxCount"],"additionalProperties":false},"PresetsResponse":{"type":"object","properties":{"object":{"type":"string","const":"list"},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"label":{"type":"string"},"length":{"type":"number"},"width":{"type":"number"},"deckHeight":{"type":"number"},"emptyWeightKg":{"type":"number"},"group":{"type":"string"}},"required":["id","label","length","width","deckHeight"],"additionalProperties":false}}},"required":["object","data"],"additionalProperties":false},"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"requestId":{"type":"string"},"param":{"type":"string"}},"required":["code","message"],"additionalProperties":false}},"required":["error"],"additionalProperties":false}}}}