{"openapi":"3.0.0","info":{"title":"Pricely API","version":"1.0.0","description":"REST API for the Pricely pricing calculator — list profiles, calculate quotes, save quotes, and manage quote status. All endpoints require a Pricely API key (Pro AI plan).","contact":{"name":"Pricely Support","url":"https://app.pricely.ink"}},"servers":[{"url":"https://app.pricely.ink","description":"Production"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"Your Pricely API key. Format: `pricely_...`. Generate one in Shop Details → API & Integrations."}},"schemas":{"PricingProfile":{"type":"object","properties":{"id":{"type":"string","description":"Profile ID (UUID)"},"userId":{"type":"string","description":"Owner user ID"},"name":{"type":"string","description":"Profile display name"},"engineType":{"type":"string","description":"Pricing engine type","enum":["COST_PLUS","CONTRACT","FLAT_RATE","HOURLY_RATE","BASIC","MATRIX","MATRIX_LITE","MATRIX_PRO","DTF","DTF_FLAT","DTF_TRANSFER","DTF_FLAT_TRANSFER","EMB_STITCH_RATE","EMB_TIERED_STITCH","EMB_FLAT_MATRIX","LASER_AREA","LASER_TIME","LASER_FLAT"]},"engineConfig":{"type":"object","description":"Engine-specific configuration object (structure varies by engineType)"},"globalRules":{"type":"object","description":"Profile-level global rules (minimums, additional fees, etc.)"},"quoteDefaults":{"type":"object","nullable":true,"description":"Editable starting values for fresh quotes only, not pricing rules or minimums.","properties":{"garmentDescription":{"type":"string","minLength":1},"garmentCostPerPiece":{"type":"number","minimum":0},"quantity":{"type":"integer","minimum":1}}},"sortOrder":{"type":"integer","description":"Display order position"},"cardColor":{"type":"string","nullable":true},"badgeColor":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"PrintLocation":{"type":"object","required":["name","colors"],"properties":{"name":{"type":"string","description":"Location label (e.g. 'Front', 'Back')"},"colors":{"type":"integer","minimum":1,"description":"Number of ink/thread colors at this location"},"widthInches":{"type":"number","minimum":0,"description":"Engraving/print width in inches (laser/DTF engines)"},"heightInches":{"type":"number","minimum":0,"description":"Engraving/print height in inches (laser/DTF engines)"}}},"GarmentLine":{"type":"object","required":["name","quantity","garmentCostPerPiece"],"properties":{"name":{"type":"string","description":"Size or style label (e.g. 'Small', 'XL')"},"quantity":{"type":"integer","minimum":1},"garmentCostPerPiece":{"type":"number","minimum":0,"description":"Wholesale cost per garment for this size/style"}}},"EmbroideryPlacement":{"type":"object","required":["placement","stitchCount"],"properties":{"placement":{"type":"string","enum":["left_chest","right_chest","hat_front","hat_side","sleeve","back","other"]},"stitchCount":{"type":"integer","minimum":1},"threadColors":{"type":"integer","minimum":1,"default":1}}},"SelectedFee":{"type":"object","required":["id"],"properties":{"id":{"type":"string","description":"Fee ID from the profile's globalRules.additionalFees"},"count":{"type":"integer","minimum":1,"default":1}}},"QuoteRequest":{"type":"object","required":["profileId","quantity","locations"],"properties":{"profileId":{"type":"string","description":"ID of the pricing profile to use"},"quantity":{"type":"integer","minimum":1,"description":"Total number of pieces / units"},"garmentCostPerPiece":{"type":"number","minimum":0,"description":"Wholesale cost per garment/blank. Omit for garment-free engines (defaults to zero)."},"locations":{"type":"array","minItems":1,"items":{"$ref":"#/components/schemas/PrintLocation"},"description":"Print/embroidery locations"},"rushDays":{"type":"integer","minimum":0,"default":0,"description":"Rush turnaround in days (0 = standard)"},"garmentLines":{"type":"array","items":{"$ref":"#/components/schemas/GarmentLine"},"description":"Per-size/style breakdown. When provided, overrides top-level quantity and garmentCostPerPiece."},"placements":{"type":"array","items":{"$ref":"#/components/schemas/EmbroideryPlacement"},"description":"Required for embroidery engines (EMB_*)"},"designWidthInches":{"type":"number","minimum":0,"description":"Required for LASER_AREA, LASER_TIME, and DTF engines"},"designHeightInches":{"type":"number","minimum":0,"description":"Required for LASER_AREA, LASER_TIME, and DTF engines"},"laserItemName":{"type":"string","description":"Required for LASER_FLAT — must match an item name in the profile config"},"materialCostPerItem":{"type":"number","minimum":0},"garmentType":{"type":"string","description":"Garment category (e.g. 'tshirt', 'hoodie')"},"isCap":{"type":"boolean"},"digitizingRequired":{"type":"boolean"},"customerSupplied":{"type":"boolean","default":false,"description":"True when the customer is supplying their own garments (zeroes garment cost and adds handling fee)"},"taxRate":{"type":"number","minimum":0,"maximum":100,"description":"Optional quote tax percentage. Omit to use the shop default; 0 disables tax."},"selectedFees":{"type":"array","items":{"$ref":"#/components/schemas/SelectedFee"},"description":"Additional fees to apply from the profile's globalRules"}}},"LineItem":{"type":"object","properties":{"label":{"type":"string"},"amount":{"type":"number"},"detail":{"type":"string"}}},"GarmentLineResult":{"type":"object","properties":{"name":{"type":"string"},"quantity":{"type":"integer"},"garmentCostPerPiece":{"type":"number"},"printCostPerPiece":{"type":"number"},"unitPrice":{"type":"number"},"lineTotal":{"type":"number"}}},"QuoteResult":{"type":"object","properties":{"unitPrice":{"type":"number","description":"Price per piece before tax"},"subtotal":{"type":"number","description":"Subtotal before any order-level discounts"},"total":{"type":"number","description":"Final total including tax"},"preTaxTotal":{"type":"number","description":"Total after discounts, before tax. Optional on legacy quotes."},"taxRate":{"type":"number","minimum":0,"maximum":100},"taxAmount":{"type":"number"},"lineItems":{"type":"array","items":{"$ref":"#/components/schemas/LineItem"}},"garmentLines":{"type":"array","items":{"$ref":"#/components/schemas/GarmentLineResult"},"description":"Per-size/style breakdown (only when garmentLines were provided in request)"},"marginSummary":{"type":"object","nullable":true,"properties":{"costPerUnit":{"type":"number"},"pricePerUnit":{"type":"number"},"marginPercent":{"type":"number"},"totalProfit":{"type":"number"}}},"warnings":{"type":"array","items":{"type":"string"},"description":"Non-fatal warnings (e.g. stitch count overflow)"},"discountType":{"type":"string","enum":["percent","flat"]},"discountValue":{"type":"number"},"discountAmount":{"type":"number"}}},"SavedQuote":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string","description":"Owner user ID"},"profileId":{"type":"string"},"profileName":{"type":"string"},"engineType":{"type":"string"},"customerName":{"type":"string"},"customerEmail":{"type":"string","nullable":true},"details":{"type":"string"},"quantity":{"type":"integer"},"quoteInput":{"type":"object","description":"Original QuoteRequest object"},"quoteResult":{"$ref":"#/components/schemas/QuoteResult"},"status":{"type":"string","enum":["draft","won","lost"]},"lostReason":{"type":"string","nullable":true,"enum":["price_too_high","went_with_competitor","no_response","project_canceled","other"]},"outcomeUpdatedAt":{"type":"string","format":"date-time","nullable":true},"quotedAt":{"type":"string","format":"date-time","nullable":true}}},"Error":{"type":"object","properties":{"message":{"type":"string"}}},"ProfileFeeSpec":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"amount":{"type":"number"},"feeType":{"type":"string","enum":["order","per_process","per_item"]}}},"ProfileInputSpec":{"type":"object","description":"Engine-specific input requirements for a pricing profile. Use this to build the right form fields before calling POST /api/quote.","properties":{"showGarmentCost":{"type":"boolean","description":"False for transfers-only, laser, or profiles whose prices already include garments."},"quoteDefaults":{"$ref":"#/components/schemas/PricingProfile/properties/quoteDefaults"},"fields":{"type":"array","description":"Editable form fields. Quantity defaults are starting values, independent of minimumOrderQty.","items":{"type":"object","additionalProperties":true}},"locationMode":{"type":"string","enum":["colors","dimensions","dtf_size_label","none"],"description":"Primary discriminator for what to show per print location. `colors` = screen printing (show a colors count per location); `dimensions` = DTF / laser (show width + height per location); `dtf_size_label` = DTF Flat (show a size dropdown per location); `none` = no location fields (BASIC, laser flat, embroidery — use placements or laserItemName instead)."},"requiresColors":{"type":"boolean","description":"True when each location needs a `colors` field (screen printing engines)."},"requiresDimensions":{"type":"boolean","description":"True when each location needs `widthInches` + `heightInches` fields (DTF, LASER_AREA, LASER_TIME)."},"dtfSizeOptions":{"type":"array","nullable":true,"items":{"type":"string"},"description":"Available size labels for the `dtfSizeLabel` field. Non-null only when `locationMode` is `dtf_size_label`."},"requiresPlacements":{"type":"boolean","description":"True for embroidery engines. Collect `placements` array instead of `locations`."},"placementOptions":{"type":"array","nullable":true,"items":{"type":"string","enum":["left_chest","right_chest","hat_front","hat_side","sleeve","back","other"]},"description":"Valid placement values for embroidery. Non-null only when `requiresPlacements` is true."},"requiresLaserItem":{"type":"boolean","description":"True for LASER_FLAT. Collect `laserItemName` instead of `locations`."},"laserItems":{"type":"array","nullable":true,"items":{"type":"string"},"description":"Available item names for `laserItemName`. Non-null only when `requiresLaserItem` is true."},"requiresMaterialCost":{"type":"boolean","description":"True for LASER_AREA and LASER_TIME. Optionally collect `materialCostPerItem` as a more specific alternative to `garmentCostPerPiece`."},"showIsCap":{"type":"boolean","description":"True for embroidery engines. Show an `isCap` toggle (applies cap surcharge)."},"showDigitizingRequired":{"type":"boolean","description":"True for embroidery engines. Show a `digitizingRequired` toggle."},"showGarmentType":{"type":"boolean","description":"True for embroidery engines. Optionally collect `garmentType` for specialty surcharges."},"customerSuppliedEnabled":{"type":"boolean","description":"True when the profile supports customer-supplied garments. Show a `customerSupplied` toggle."},"minimumOrderQty":{"type":"integer","description":"Minimum order quantity. 0 means no minimum. Validate before calling POST /api/quote."},"additionalFees":{"type":"array","items":{"$ref":"#/components/schemas/ProfileFeeSpec"},"description":"Available additional fees. Pass selected fee IDs in `selectedFees` when calling POST /api/quote."}}},"ProfileInputsResponse":{"type":"object","properties":{"profileId":{"type":"string"},"profileName":{"type":"string"},"engineType":{"type":"string"},"inputSpec":{"$ref":"#/components/schemas/ProfileInputSpec"}}}}},"paths":{"/api/profiles":{"get":{"operationId":"listProfiles","summary":"List pricing profiles","description":"Returns all pricing profiles for the authenticated user.","tags":["Profiles"],"responses":{"200":{"description":"Array of pricing profiles","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PricingProfile"}}}}},"401":{"description":"Invalid or missing API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/profiles/{id}":{"get":{"operationId":"getProfile","summary":"Get a pricing profile","description":"Returns full details for a single pricing profile including engine config and global rules.","tags":["Profiles"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Profile ID"}],"responses":{"200":{"description":"Pricing profile","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PricingProfile"}}}},"404":{"description":"Profile not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/profiles/{id}/inputs":{"get":{"operationId":"getProfileInputs","summary":"Get input spec for a profile","description":"Returns a structured input spec describing exactly what fields to collect from users before calling POST /api/quote. Call this once when the user selects a print type — read `inputSpec.locationMode` to determine what form fields to show, then POST /api/quote in real time as inputs change.","tags":["Profiles"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Profile ID"}],"responses":{"200":{"description":"Profile input specification","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProfileInputsResponse"},"examples":{"screenPrinting":{"summary":"Screen printing profile","value":{"profileId":"<profile-id>","profileName":"Standard Screen Print","engineType":"COST_PLUS","inputSpec":{"locationMode":"colors","requiresColors":true,"requiresDimensions":false,"dtfSizeOptions":null,"requiresPlacements":false,"placementOptions":null,"requiresLaserItem":false,"laserItems":null,"requiresMaterialCost":false,"showIsCap":false,"showDigitizingRequired":false,"showGarmentType":false,"customerSuppliedEnabled":false,"minimumOrderQty":12,"additionalFees":[{"id":"fee-1","name":"Screen Fee","amount":25,"feeType":"order"}]}}},"dtfFlat":{"summary":"DTF Flat profile","value":{"profileId":"<profile-id>","profileName":"DTF Flat Rate","engineType":"DTF_FLAT","inputSpec":{"locationMode":"dtf_size_label","requiresColors":false,"requiresDimensions":false,"dtfSizeOptions":["Pocket","A5","A4","A3","Full Front"],"requiresPlacements":false,"placementOptions":null,"requiresLaserItem":false,"laserItems":null,"requiresMaterialCost":false,"showIsCap":false,"showDigitizingRequired":false,"showGarmentType":false,"customerSuppliedEnabled":true,"minimumOrderQty":0,"additionalFees":[]}}},"embroidery":{"summary":"Embroidery profile","value":{"profileId":"<profile-id>","profileName":"Embroidery Stitch Rate","engineType":"EMB_STITCH_RATE","inputSpec":{"locationMode":"none","requiresColors":false,"requiresDimensions":false,"dtfSizeOptions":null,"requiresPlacements":true,"placementOptions":["left_chest","right_chest","hat_front","hat_side","sleeve","back","other"],"requiresLaserItem":false,"laserItems":null,"requiresMaterialCost":false,"showIsCap":true,"showDigitizingRequired":true,"showGarmentType":true,"customerSuppliedEnabled":false,"minimumOrderQty":0,"additionalFees":[]}}}}}}},"404":{"description":"Profile not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/quote":{"post":{"operationId":"calculateQuote","summary":"Calculate a quote","description":"Calculates a price quote using the specified pricing profile. Returns a full QuoteResult with unit price, line items, and totals. Does not save the quote.","tags":["Quotes"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuoteRequest"},"examples":{"screenPrinting":{"summary":"Basic screen printing quote","value":{"profileId":"<profile-id>","quantity":72,"garmentCostPerPiece":4.5,"locations":[{"name":"Front","colors":2}],"rushDays":0,"selectedFees":[]}},"embroidery":{"summary":"Embroidery quote with placement","value":{"profileId":"<profile-id>","quantity":24,"garmentCostPerPiece":8,"locations":[{"name":"Left Chest","colors":3}],"placements":[{"placement":"left_chest","stitchCount":7500,"threadColors":3}],"rushDays":0,"selectedFees":[]}}}}}},"responses":{"200":{"description":"Calculated quote result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuoteResult"}}}},"400":{"description":"Validation or calculation error (e.g. profile not found, missing embroidery placements, minimum order not met)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/quotes":{"get":{"operationId":"listQuotes","summary":"List saved quotes","description":"Returns all saved quotes for the authenticated user, ordered by date (newest first).","tags":["Quotes"],"responses":{"200":{"description":"Array of saved quotes","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/SavedQuote"}}}}}}},"post":{"operationId":"saveQuote","summary":"Save a quote","description":"Saves a pre-calculated quote for a customer. Provide the quoteInput (QuoteRequest) and quoteResult (QuoteResult) from a prior calculateQuote call.","tags":["Quotes"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["profileId","profileName","engineType","customerName","quantity","quoteInput","quoteResult"],"properties":{"profileId":{"type":"string"},"profileName":{"type":"string"},"engineType":{"type":"string"},"customerName":{"type":"string","minLength":1},"customerEmail":{"type":"string","format":"email","nullable":true},"details":{"type":"string","description":"Job notes or description"},"quantity":{"type":"integer","minimum":1},"quoteInput":{"$ref":"#/components/schemas/QuoteRequest","description":"The original QuoteRequest used to calculate the quote"},"quoteResult":{"$ref":"#/components/schemas/QuoteResult","description":"The QuoteResult returned by POST /api/quote"},"quotedAt":{"type":"string","format":"date-time","description":"Override the quote date (defaults to now)"}}}}}},"responses":{"200":{"description":"Saved quote","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedQuote"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/quotes/{id}":{"get":{"operationId":"getQuote","summary":"Get a saved quote","description":"Returns full details for a single saved quote including quoteInput and quoteResult.","tags":["Quotes"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Quote ID"}],"responses":{"200":{"description":"Saved quote","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedQuote"}}}},"404":{"description":"Quote not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/quotes/{id}/status":{"patch":{"operationId":"updateQuoteStatus","summary":"Update quote status","description":"Updates the status of a saved quote to 'won', 'lost', or 'draft'.","tags":["Quotes"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Quote ID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["draft","won","lost"],"description":"New status for the quote"},"lostReason":{"type":"string","nullable":true,"enum":["price_too_high","went_with_competitor","no_response","project_canceled","other"],"description":"Required when status is 'lost'"}}}}}},"responses":{"200":{"description":"Updated quote","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedQuote"}}}},"400":{"description":"Invalid status or lost reason","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Quote not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}