{"openapi":"3.1.0","info":{"title":"GET /api/v1/inventory/products/lookup","version":"1.0.0","description":"Lookup variant by barcode or SKU"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/inventory/products/lookup":{"get":{"tags":["inventory:products"],"summary":"Lookup variant by barcode or SKU","description":"Resolve a single variant by a scannable identifier. Tries barcode first, then falls back to SKU. Used by receiving, cycle counting, and point-of-sale flows.","operationId":"lookup_variant","parameters":[{"name":"barcode","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Scannable barcode (UPC/EAN/QR).","title":"Barcode"},"description":"Scannable barcode (UPC/EAN/QR)."},{"name":"sku","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Stock Keeping Unit fallback.","title":"Sku"},"description":"Stock Keeping Unit fallback."},{"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/SuccessEnvelope_VariantResponse_"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"error":"validation_error","message":"Validation failed: due_date: Input should be a valid date","errors":{"due_date":"Input should be a valid date"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"error":"not_found","message":"Resource not found","code":"NOT_FOUND_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error - Request body or parameters failed validation","content":{"application/json":{"example":{"error":"validation_error","message":"Validation failed: amount: Input should be a valid integer","errors":{"amount":"Input should be a valid integer"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":"unauthorized","message":"Authentication required","code":"AUTH_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":"forbidden","message":"You don't have permission to access this resource","code":"AUTH_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"}}}}},"x-fastapi-operation-id":"lookup_variant_api_v1_inventory_products_lookup_get"}}},"components":{"schemas":{"InventorySummary":{"properties":{"on_hand":{"type":"number","minimum":0.0,"title":"On Hand","description":"Total physical inventory quantity in your possession.","default":0},"available":{"type":"number","minimum":0.0,"title":"Available","description":"Quantity available for allocation.","default":0},"in_transit":{"type":"number","minimum":0.0,"title":"In Transit","description":"Quantity currently being shipped to your location.","default":0},"ordered":{"type":"number","minimum":0.0,"title":"Ordered","description":"Quantity ordered from suppliers but not yet shipped.","default":0}},"type":"object","title":"InventorySummary","description":"Summary of inventory quantities for a product variant.\n\nTracks different inventory states to support proper stock management\nand prevent overselling.","example":{"available":100,"in_transit":25,"on_hand":100,"ordered":50},"examples":[{"available":100,"in_transit":25,"on_hand":100,"ordered":50}]},"SuccessEnvelope_VariantResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"},"code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Code"},"data":{"anyOf":[{"$ref":"#/components/schemas/VariantResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[VariantResponse]"},"VariantResponse":{"properties":{"id":{"type":"string","title":"Id","description":"Variant UUID."},"product_id":{"type":"string","title":"Product Id","description":"Parent product UUID."},"business_id":{"type":"string","title":"Business Id","description":"Business UUID."},"created_at":{"type":"string","format":"date-time","title":"Created At","description":"Creation timestamp."},"updated_at":{"type":"string","format":"date-time","title":"Updated At","description":"Last update timestamp."},"name":{"type":"string","title":"Name","description":"Variant name."},"sku":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Sku","description":"Stock Keeping Unit."},"manufacturer_sku":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Manufacturer Sku","description":"Manufacturer's SKU."},"barcode":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Barcode","description":"Scannable barcode (UPC/EAN/QR). Distinct from SKU."},"archived":{"type":"boolean","title":"Archived","description":"Whether variant is archived.","default":false},"price":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Price","description":"Unit price in dollars (legacy field, prefer unit_price)."},"cost":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Cost","description":"Unit cost in dollars (legacy field, prefer unit_cost)."},"inventory_quantity":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Inventory Quantity","description":"Current inventory quantity (legacy, prefer inventory.on_hand)."},"shopify_variant_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Shopify Variant Id","description":"Shopify variant ID if synced from Shopify."},"stripe_price_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Stripe Price Id","description":"Stripe price ID if synced to Stripe."},"stripe_product_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Stripe Product Id","description":"Stripe product ID if synced to Stripe."},"unit_price":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Unit Price","description":"Sale price in cents."},"unit_cost":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Unit Cost","description":"Cost price in cents."},"unit_cost_precise":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Unit Cost Precise","description":"Precise unit cost in dollars with sub-cent precision."},"uom":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Uom","description":"Unit of measure: EA, LB, G, KG, OZ, etc."},"purchase_uom":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Purchase Uom","description":"Unit bought in"},"purchase_uom_factor":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Purchase Uom Factor","description":"Stock units per purchase unit"},"inventory_category":{"anyOf":[{"type":"string","enum":["raw_material","packaging","finished_good"]},{"type":"null"}],"title":"Inventory Category","description":"Which inventory ledger this item's cost sits in: raw_material, packaging or finished_good. Production runs and counts post by it."},"default_vendor_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Default Vendor Id","description":"Preferred vendor UUID."},"tax_code_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tax Code Id","description":"Tax code deciding whether this variant is charged sales tax."},"inventory":{"anyOf":[{"$ref":"#/components/schemas/InventorySummary"},{"type":"null"}],"description":"Detailed inventory breakdown."},"product_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Product Name","description":"Parent product name (resolved)."},"margin_cents":{"type":"integer","title":"Margin Cents","description":"Profit margin in cents (unit_price - unit_cost).","readOnly":true},"margin_percentage":{"type":"number","title":"Margin Percentage","description":"Profit margin as percentage of sale price.","readOnly":true}},"additionalProperties":true,"type":"object","required":["id","product_id","business_id","created_at","updated_at","name","margin_cents","margin_percentage"],"title":"VariantResponse","description":"Response schema for a product variant.\n\nContains pricing, inventory, and margin information.\nIncludes computed fields for profit margin calculations.","example":{"archived":false,"business_id":"019ab37c-b051-7000-8000-000000000001","created_at":"2024-01-10T10:30:00Z","id":"019ab37c-0a71-7000-8000-000000000001","inventory":{"available":50,"in_transit":0,"on_hand":50,"ordered":0},"manufacturer_sku":"MFR-12345","margin_cents":1799,"margin_percentage":60.02,"name":"Large - Blue","product_id":"019ab37c-9a0d-7000-8000-000000000001","product_name":"Premium Widget","sku":"WIDGET-PRO-LG-BLU","unit_cost":1200,"unit_price":2999,"updated_at":"2024-01-15T14:00:00Z"},"examples":[{"archived":false,"business_id":"019ab37c-b051-7000-8000-000000000001","created_at":"2024-01-10T10:30:00Z","id":"019ab37c-0a71-7000-8000-000000000001","inventory":{"available":50,"in_transit":0,"on_hand":50,"ordered":0},"manufacturer_sku":"MFR-12345","margin_cents":1799,"margin_percentage":60.02,"name":"Large - Blue","product_id":"019ab37c-9a0d-7000-8000-000000000001","product_name":"Premium Widget","sku":"WIDGET-PRO-LG-BLU","unit_cost":1200,"unit_price":2999,"updated_at":"2024-01-15T14:00:00Z"}]},"ErrorResponse":{"title":"ErrorResponse","type":"object","description":"Envelope returned by every non-2xx response. Branch on `code` (stable) rather than `message` (human-readable, may change).","required":["error","message","code"],"properties":{"error":{"type":"string","description":"Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`."},"message":{"type":"string","description":"Human-readable explanation, safe to show to end users."},"code":{"type":"string","description":"Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`)."},"request_id":{"type":"string","description":"Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied."},"errors":{"type":"object","additionalProperties":{"type":"string"},"description":"Field-level validation messages keyed by field name. Present on 400/422 validation failures only."}}}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}