{"openapi":"3.1.0","info":{"title":"GET /api/v1/inventory/cost-history","version":"1.0.0","description":"Landed COGS history"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/inventory/cost-history":{"get":{"tags":["inventory:cost_history"],"summary":"Landed COGS history","description":"Return cost snapshots grouped by variant for the last N months. Powers the Landed COGS sparkline + material/freight/processing breakdown.","operationId":"get_cost_history_api_v1_inventory_cost_history_get","parameters":[{"name":"months","in":"query","required":false,"schema":{"type":"integer","maximum":36,"minimum":1,"description":"Window size in months (default 12).","default":12,"title":"Months"},"description":"Window size in months (default 12)."},{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-business-id","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Business-Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CostHistoryResponse"}}}},"401":{"description":"Unauthorized - Authentication required","content":{"application/json":{"example":{"detail":"Not authenticated"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"detail":"Not enough permissions"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"CostHistoryResponse":{"properties":{"window_months":{"type":"integer","title":"Window Months"},"variants":{"items":{"$ref":"#/components/schemas/VariantCostHistory"},"type":"array","title":"Variants"}},"type":"object","required":["window_months","variants"],"title":"CostHistoryResponse"},"CostSnapshotPoint":{"properties":{"snapshot_month":{"type":"string","format":"date","title":"Snapshot Month"},"material_per_unit":{"type":"integer","title":"Material Per Unit"},"freight_per_unit":{"type":"integer","title":"Freight Per Unit"},"processing_per_unit":{"type":"integer","title":"Processing Per Unit"},"total_per_unit":{"type":"integer","title":"Total Per Unit"},"source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source"}},"type":"object","required":["snapshot_month","material_per_unit","freight_per_unit","processing_per_unit","total_per_unit"],"title":"CostSnapshotPoint"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"VariantCostHistory":{"properties":{"variant_id":{"type":"string","title":"Variant Id"},"variant_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Variant Name"},"variant_sku":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Variant Sku"},"product_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Product Id"},"product_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Product Name"},"points":{"items":{"$ref":"#/components/schemas/CostSnapshotPoint"},"type":"array","title":"Points"},"latest_total_per_unit":{"type":"integer","title":"Latest Total Per Unit","default":0},"trailing_delta_pct":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Trailing Delta Pct","description":"Percent change vs. the earliest point in the window. Null if <2 points."}},"type":"object","required":["variant_id"],"title":"VariantCostHistory"}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}