{"openapi":"3.1.0","info":{"title":"GET /api/v1/inventory/reports/margin-by-sku","version":"1.0.0","description":"Margin-by-SKU report (landed cost + sales velocity)"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/inventory/reports/margin-by-sku":{"get":{"tags":["inventory:reports"],"summary":"Margin-by-SKU report (landed cost + sales velocity)","description":"Returns per-variant landed cost (latest cost snapshot), current sell price, gross margin, and trailing Shopify sales over the configured lookback window. Powers the Landed COGS 'Truth' tab.","operationId":"get_margin_by_sku_api_v1_inventory_reports_margin_by_sku_get","parameters":[{"name":"lookback_days","in":"query","required":false,"schema":{"type":"integer","maximum":365,"minimum":1,"description":"Trailing window (days) used to compute revenue + units sold.","default":30,"title":"Lookback Days"},"description":"Trailing window (days) used to compute revenue + units sold."},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":1000,"minimum":1,"description":"Max variants returned (sorted by trailing revenue desc).","default":100,"title":"Limit"},"description":"Max variants returned (sorted by trailing revenue desc)."},{"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/MarginByVariantResponse"}}}},"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":{"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"MarginByVariantResponse":{"properties":{"rows":{"items":{"$ref":"#/components/schemas/MarginRow"},"type":"array","title":"Rows"},"lookback_days":{"type":"integer","title":"Lookback Days","default":30},"totals":{"$ref":"#/components/schemas/MarginTotals"}},"type":"object","title":"MarginByVariantResponse"},"MarginLayerBreakdown":{"properties":{"material":{"type":"integer","title":"Material","default":0},"packaging":{"type":"integer","title":"Packaging","default":0},"processing":{"type":"integer","title":"Processing","default":0},"freight":{"type":"integer","title":"Freight","default":0},"duties":{"type":"integer","title":"Duties","default":0},"handling":{"type":"integer","title":"Handling","default":0}},"type":"object","title":"MarginLayerBreakdown","description":"Six-layer landed-cost breakdown (cents per unit)."},"MarginRow":{"properties":{"variant_id":{"type":"string","title":"Variant Id"},"product_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Product Id"},"product_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Product Name"},"variant_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Variant Name"},"sku":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Sku"},"price_cents":{"type":"integer","title":"Price Cents"},"landed_cost_cents":{"type":"integer","title":"Landed Cost Cents"},"margin_cents":{"type":"integer","title":"Margin Cents"},"margin_pct":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Margin Pct"},"layers":{"$ref":"#/components/schemas/MarginLayerBreakdown"},"units_sold":{"type":"integer","title":"Units Sold","default":0},"revenue_cents":{"type":"integer","title":"Revenue Cents","default":0},"cogs_cents":{"type":"integer","title":"Cogs Cents","default":0},"daily_velocity":{"type":"number","title":"Daily Velocity","default":0.0},"snapshot_month":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Snapshot Month"},"snapshot_source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Snapshot Source"}},"type":"object","required":["variant_id","price_cents","landed_cost_cents","margin_cents","layers"],"title":"MarginRow","description":"Per-SKU margin row for the margin-by-SKU report."},"MarginTotals":{"properties":{"revenue_cents":{"type":"integer","title":"Revenue Cents","default":0},"cogs_cents":{"type":"integer","title":"Cogs Cents","default":0},"gross_margin_cents":{"type":"integer","title":"Gross Margin Cents","default":0},"units_sold":{"type":"integer","title":"Units Sold","default":0}},"type":"object","title":"MarginTotals"},"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"}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}