{"openapi":"3.1.0","info":{"title":"Stock Substitution Assignment","version":"1.0.0","description":"Maximize fulfilled demand units across order lines that can accept specific substitute SKUs, with exact allocation and shortage details.","contact":{"email":"jeremy@jeremycarter.ca"}},"servers":[{"url":"https://gptenv-x402-catalog.defcronyke.workers.dev"}],"paths":{"/stock-substitution-assignment/v1/check":{"post":{"operationId":"stock_substitution_assignment","summary":"Maximize fulfilled demand units across order lines that can accept specific substitute SKUs, with exact allocation and shortage details.","x-payment-info":{"protocols":[{"x402":{}}],"price":{"mode":"fixed","currency":"USD","amount":"0.04"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"stock":{"maxItems":80,"type":"array","items":{"type":"object","properties":{"sku":{"type":"string","minLength":1,"maxLength":80},"units":{"type":"integer","minimum":0,"maximum":100000000}},"required":["sku","units"],"additionalProperties":false}},"demand":{"maxItems":30,"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":80},"units":{"type":"integer","minimum":1,"maximum":100000000},"acceptable_skus":{"minItems":1,"maxItems":8,"type":"array","items":{"type":"string","minLength":1,"maxLength":80}}},"required":["id","units","acceptable_skus"],"additionalProperties":false}}},"required":["stock","demand"],"additionalProperties":false},"example":{"stock":[{"sku":"A","units":2},{"sku":"B","units":3}],"demand":[{"id":"flex","units":3,"acceptable_skus":["A","B"]},{"id":"A-only","units":2,"acceptable_skus":["A"]}]}}}},"responses":{"200":{"description":"Service result","content":{"application/json":{"schema":{"type":"object"},"example":{"fulfilled_units":5,"lines":[{"id":"flex","assignments":[{"sku":"B","units":3}],"short_units":0},{"id":"A-only","assignments":[{"sku":"A","units":2}],"short_units":0}]}}}},"400":{"description":"Invalid request"},"402":{"description":"x402 exact payment required on Base"},"503":{"description":"Payment unavailable"}}}}}}